Sign in to follow this  
Followers 0
klaki

Outlook PST Question

22 posts in this topic

I have a PST file loaded in my Outlook. What I want to do is to open the Inbox inside of my PST and go through each email. I want to take each email and copy certain parts of the body to an external file. Is this possible? If so, any help would be appreciated.

Thanks in advance,

Klaki

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think you'd have to interact with Outlook to do this. Check out the MSDN Articles relating to VBA for Outlook 2003.

Then, of course, you need to convert the code for AutoIt, but that's child's play.

*EDIT* BTW, I would throw together some code, but we use *insert several explatives here* Lotus Notes at work and I don't have the energy to think about it at home.

Edited by c0deWorm

My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

I think you'd have to interact with Outlook to do this. Check out the MSDN Articles relating to VBA for Outlook 2003.

Then, of course, you need to convert the code for AutoIt, but that's child's play.

*EDIT* BTW, I would throw together some code, but we use *insert several explatives here* Lotus Notes at work and I don't have the energy to think about it at home.

Thanks for the link. I will try to piece together something.

Share this post


Link to post
Share on other sites

Thanks for the link. I will try to piece together something.

if you can explain what exactly you want it to do, i can write you some VBA script to do it directly from outlook...


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

if you can explain what exactly you want it to do, i can write you some VBA script to do it directly from outlook...

Open a folder (Logs) that is inside a personal folder.

Mailbox - Me (Exchange Mailbox)

|_Calander

|_Inbox

...

Personal Folder

|_Inbox

|_Logs

...

Then take the body in each email, manipulate it, and save certain lines to a new file.

Here is what I got. It works, but I have to use .PickFolder. I want a way to do this without using that. Here is the code:

MsgBox(0,"test","Creating Outlook Object")
$oOutlook = ObjCreate("Outlook.Application")
MsgBox(0,"test","Getting Namespace")
$oNameSpace = $oOutlook.GetNamespace("MAPI")
MsgBox(0,"test","Connecting to Personal Folder")
$oFld = $oNameSpace.PickFolder
$oEmails = $oFld.Items
$fLog = FileOpen("c:\test.txt",1)
For $iLoop = 1 to $oEmails.Count
;MsgBox(0,"test",$oEmails.Item($iLoop).Body)
    $aLog = StringSplit($oEmails.Item($iLoop).Body,Chr(13))
    For $iLoop2 = 2 to $aLog[0] 
        $aLog2 = StringSplit($aLog[$iLoop2],"-")
        For $iLoop3 = 2 to $aLog2[0]
        ;MsgBox(0,"test","Orginal Line: " & $aLog[$iLoop2])
            If (StringInStr($aLog2[3],"Log") = 0) Then
                $aLog3 = StringSplit($aLog2[4],",")
                $aLog4 = StringSplit($aLog2[5],",")
                If (($aLog3[2] = 80) Or ($aLog4[2] = 80)) Then
                ;MsgBox(0,"test",$aLog[$iLoop2])
                    FileWriteLine($fLog,$aLog[$iLoop2])
                EndIf
            EndIf
        Next
    ;MsgBox(0,"test",$aLog[$iLoop2])
    Next
Next
MsgBox(0,"test","Log completed..... closing")
FileClose($fLog)
$oEmails = ""
$oFld = ""
$oNameSpace = ""
$oOutlook = ""
Exit

Thanks in advance,

Klaki

Edited by klaki

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Open a folder (Logs) that is inside a personal folder.

Mailbox - Me (Exchange Mailbox)

|_Calander

|_Inbox

...

Personal Folder

|_Inbox

|_Logs

...

Then take the body in each email, manipulate it, and save certain lines to a new file.

Here is what I got. It works, but I have to use .PickFolder. I want a way to do this without using that. Here is the code:

MsgBox(0,"test","Creating Outlook Object")
$oOutlook = ObjCreate("Outlook.Application")
MsgBox(0,"test","Getting Namespace")
$oNameSpace = $oOutlook.GetNamespace("MAPI")
MsgBox(0,"test","Connecting to Personal Folder")
$oFld = $oNameSpace.PickFolder
$oEmails = $oFld.Items
$fLog = FileOpen("c:\test.txt",1)
For $iLoop = 1 to $oEmails.Count
;MsgBox(0,"test",$oEmails.Item($iLoop).Body)
    $aLog = StringSplit($oEmails.Item($iLoop).Body,Chr(13))
    For $iLoop2 = 2 to $aLog[0] 
        $aLog2 = StringSplit($aLog[$iLoop2],"-")
        For $iLoop3 = 2 to $aLog2[0]
;MsgBox(0,"test","Orginal Line: " & $aLog[$iLoop2])
            If (StringInStr($aLog2[3],"Log") = 0) Then
                $aLog3 = StringSplit($aLog2[4],",")
                $aLog4 = StringSplit($aLog2[5],",")
                If (($aLog3[2] = 80) Or ($aLog4[2] = 80)) Then
        ;MsgBox(0,"test",$aLog[$iLoop2])
                    FileWriteLine($fLog,$aLog[$iLoop2])
                EndIf
            EndIf
        Next
;MsgBox(0,"test",$aLog[$iLoop2])
    Next
Next
MsgBox(0,"test","Log completed..... closing")
FileClose($fLog)
$oEmails = ""
$oFld = ""
$oNameSpace = ""
$oOutlook = ""
Exit

Thanks in advance,

Klaki

instead of

$oFld = $oNameSpace.PickFolder

try:

$oFld = $oNameSpace.Folders("Folder Name")
Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Just out of curiousity, is this something you want to have run everyday, or is this a one-time thing? Judging from the code, it's a one-time thing, so the rest of this post is irrelevant. I say this because I don't see any code to check for whether the email is unread before touching it, nor does it delete the emails once it reads them.

If you are trying to do this on a regular basis or something, why not script the POP3 or IMAP connection instead of scripting Outlook? I think I saw some email UDF's in the forums at some point. Try searching if you're interested.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

Just out of curiousity, is this something you want to have run everyday, or is this a one-time thing? Judging from the code, it's a one-time thing, so the rest of this post is irrelevant. I say this because I don't see any code to check for whether the email is unread before touching it, nor does it delete the emails once it reads them.

If you are trying to do this on a regular basis or something, why not script the POP3 or IMAP connection instead of scripting Outlook? I think I saw some email UDF's in the forums at some point. Try searching if you're interested.

It will be a monthly thing. I haven't tried doing it through IMAP. I will have to do some research on how to do so. I will be adding the "Move email" function later.

Share this post


Link to post
Share on other sites

It will be a monthly thing. I haven't tried doing it through IMAP. I will have to do some research on how to do so. I will be adding the "Move email" function later.

did the replacement i suggested work for you?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

did the replacement i suggested work for you?

No, I used the following:

$oFld = $oNameSpace.Folders("Test Personal Folders").Folder("Inbox")

And it gave me an error. The "Test Personal Folders" is the name of the personal folders and "Inbox" is where all the emails I want to sift through are located. Am I doing something wrong?

Thanks again

Share this post


Link to post
Share on other sites

No, I used the following:

$oFld = $oNameSpace.Folders("Test Personal Folders").Folder("Inbox")

And it gave me an error. The "Test Personal Folders" is the name of the personal folders and "Inbox" is where all the emails I want to sift through are located. Am I doing something wrong?

Thanks again

try:

$oPfFld = $oNameSpace.Folders("Test Personal Folders")
$oFld = $PfFld.Folders("Inbox")

the code you tried should have worked though... make sure that you're using the EXACT folder names.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

try:

$oPfFld = $oNameSpace.Folders("Test Personal Folders")
$oFld = $PfFld.Folders("Inbox")

the code you tried should have worked though... make sure that you're using the EXACT folder names.

Cam, it worked the original way. I put Folder when I should have put Folders, with the S. Thanks for getting that part fixed. Do you know by chance how to get the "Program is trying to access your folders" warning? I think if I do it using IMAP like codeworm suggested, it will work, but don't know how to do that.

Thanks bunches!

Share this post


Link to post
Share on other sites

Cam, it worked the original way. I put Folder when I should have put Folders, with the S. Thanks for getting that part fixed. Do you know by chance how to get the "Program is trying to access your folders" warning? I think if I do it using IMAP like codeworm suggested, it will work, but don't know how to do that.

Thanks bunches!

not sure i'm understanding... you WANT a notification that your folders are being accessed?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

not sure i'm understanding... you WANT a notification that your folders are being accessed?

When it accesses the folder, Outlook pops up a box and asks if you want to allow access to your email. You can set it for 1, 5, etc. minutes. Here is the box: Posted Image

Share this post


Link to post
Share on other sites

When it accesses the folder, Outlook pops up a box and asks if you want to allow access to your email. You can set it for 1, 5, etc. minutes. Here is the box: Posted Image

and you WANT that to pop up? or no?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

and you WANT that to pop up? or no?

NO popup, just extra clicks.

Share this post


Link to post
Share on other sites

Use ControlSend and ControlClick... or I think you can disable that altogether in the security options somewhere.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

If you are seriously considering scripting POP3 for this, you might look at this thread or this thread.

Edited by c0deWorm

My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

If you are seriously considering scripting POP3 for this, you might look at this thread or this thread.

I don't believe POP3 is turned on at the server, so IMAP would be my only option, but thanks for the links, I will definately look them over.

Share this post


Link to post
Share on other sites

So is this an Exchange server your Outlook is connected to then? How is the email getting into the PST? If POP3 is disabled on the server, then most likely so is IMAP. I guess you'll have to do it this way.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0