import win32com.client
outlook=win32com.clent.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox=outlook.GetDefaultFolder(6)
messages=inbox.Items
message.messages.GetLast()
body_content=message.Body
print(body_content)
This will print the body of an email in my inbox. What I want to do is to reveal what is happening at each stage of this code so that I may better understand it, however when I try to print inbox, messages I get:
<COMObject <unknown>>
How do I reveal this so that I can begin to see what I'm working with.
I'm also looking for a place which has clear documentation surrounding using python to interact with MS Outlook, if anyone can share.
Try here:
In the outlook object model, most objects have a Class
property, which returns an enumeration of type OlObjectType
, saying what type of object it is. Other properties common to outlook (and indeed MS Office) object are Parent
and Application
.
If you really want to, it should be easy enough to make a function describe_outlook_object
which returns a string with useful information. You will have to write it yourself of course.
Alternatively if you just want to explore the object model, you could do worse than hit Alt+F11 in Outlook and have a play with Visual Basic. (You will have to enable macros.)