Automate Grabbing Email From Outlook On Shared Folder

D

darin.hensley

I am trying to automate Outlook mail client by retrieving a message with anattachment, using win32com. The message box is a shared folder that is notreally 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top