Phoenix Phoenix - 1 year ago 92
Python Question

Python - Reveal a COM object

import win32com.client

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.

Ben Ben
Answer Source

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.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download