Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Outlook Personal Folders

by nnigam (Novice)
on Apr 13, 2005 at 17:01 UTC ( [id://447506]=perlquestion: print w/replies, xml ) Need Help??

nnigam has asked for the wisdom of the Perl Monks concerning the following question:

I am looking for a module to open outlook personal folders and save the messages as text files and attachments in native format all named according to the message id or some related format so that they are linked together. I see Barbie's mail::outlook, but that is for the actual mail client and sending mail, not for personal folders. If no such module exists, any guidance in writing one would be appreciated.

Replies are listed 'Best First'.
Re: Outlook Personal Folders
by aquarium (Curate) on Apr 13, 2005 at 17:56 UTC
    Either manually or as suggested use OLE to first export the whole mailbox as a text file (mailbox only, not contacts etc). Then process the text file to split it up into individual files. If you try to use OLE to do the whole job, then you'll need to programmatically select each email in outlook...which will probably prove quite difficult
    the hardest line to type correctly is: stty erase ^H
      Thanks acquarium and natetut. I found a link to a perlmonk sample code snipit. I had to modify the code a little bit since the original did not work, but I think I have it working now. The only header information that I am able to get are the Sendername, To, Subject and Body. I am unable to get the messageid, or the date, or any other header information and I do not see them anywhere in win32 ole that I could use to modify the code for them. I added a counter and am renaming the images in sequential order but by this method the same messge will have different id's depending on when I run the script. This is working great for my inbox. However, I do not see where or how to open a standalone PST file.
Re: Outlook Personal Folders
by NateTut (Deacon) on Apr 13, 2005 at 17:12 UTC
    Here's a way to do it on Lotus Notes 136382 that plus Win32::OLE should get you started.
Re: Outlook Personal Folders
by maa (Pilgrim) on Apr 14, 2005 at 07:21 UTC

    Hi, nnigam

    There are only a couple of ways of doing this (opening the pst).

    1. As part of Outlook or MAPI where a pst file is represented as a Message Store
    2. As an individual file

    I don't know how to do (2) but I know a project that does. Have a look at LibPST at either http://sourceforge.net/projects/ol2mbox or http://freshmeat.net/projects/libpst/. If you can convert the pst to mbox format you can then use one of the standard mail modules to do what you want.

    HTH --
    Mark

      Thank you. Both point to libpst, and it looks promising. I will have to compile it though before I can try it out. Is a compiled version available anywhere? This would be good, because I have found a program, Mhonarc that can convert the mbox format to html pages, and then I have created a perl script to convert them all to text format which is what I want. Can't have a virus in text. How would I go about 1. Looking over Win32::Ole, I do not see how to open message store folders. I will play around with this somemore today and see what I can find out.
        OK. I do not have a C compiler here so could not compile the libpst files. I will do that to be able to process standalone pst files without the need for outlook.

        I have converted an old sample program I saw on this website to handle any folder in outlook and export messages as text files named msgXXXXX in order. All attachments are also exported in native format with the msgxxxxx tacked on to the beginning of the file.

        If anyone is interested, I would be willing to post the working code here. Currently, I just modify the source code to point to the folder to process, but may make a front end to pass as parameters.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://447506]
Approved by moot
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-19 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found