Extracting message attachments from PST files Microsoft Outlook using python

62 views Asked by At

I have a PST file with messages. I need to extract all attachments in messages using Python and save them separately in another directory with the same names as they actually have. Please tell me how I can do this?

I want to add one important caveat: I am developing a program for Linux, and more specifically, I use Ubuntu.

1

There are 1 answers

4
Dmitry Streblechenko On

In Outlook Object Model, call Application.Session.AddStore, retrieve the new Store object from the Application.Session.Stores collection (AddStore does not return the new Store object), call Store.GetRootFolder to get the top level MAPIFolder object, recursively process its MAPIFolder.Folders and MAPIFolder.Items collections to extract messages. For each MailItem object, process its attachments (MailItem.Attachments collection) and call Attachment.SaveAsFile.