Automate Grabbing Email From Outlook On Shared Folder

darin.hensley at gmail.com darin.hensley at gmail.com
Sat May 25 23:09:08 EDT 2013


I am trying to automate Outlook mail client by retrieving a message with an attachment, using win32com. The message box is a shared folder that is not really underneath root folder inbox, so I had no success with inbox = mapi.GetDefaultFolder(6). However, I did have some success with:

    import win32com.client
    outlook = win32com.client.Dispatch("Outlook.Application")
    mapi = outlook.GetNamespace("MAPI").Folders
    print mapi[7]

In which the output is "Mailbox - Foo Operations"--- the folder I want.

However, if I tried:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
mapi = outlook.GetNamespace("MAPI").Folders
messages = mapi[7].Items
message = messages.getLast()
body_content = message.body
print body_content

I get no success. So I am pretty much stuck. I googled many things but no success. I prefer to win32com since I don't have to use a login in the script. But if this is possible with another Python module with no login requirement that would be great also.




More information about the Python-list mailing list