3

I am trying to iterate over my email box and find an email with a specific subject. I am using:

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
                                    # the inbox. You can change that number to reference
                                    # any other folder
messages = inbox.Items
message = messages.GetLast()
print(message)
body_content = message.body
print body_content

Does anyone know where I can find documentation for this. I would like to use a GetAll() function then filter by subject, or a getSubject() function, but I can't find documentation on this at all. Any help would be great.

3
  • 1
    Python very good self documentation will not help you here. Go for the documentation of COM object you are using, they usually have nice looking help files about that. Commented May 13, 2014 at 15:54
  • where would I find that? I have looked no luck Commented May 13, 2014 at 16:01
  • 1
    what about msdn.microsoft.com/en-us/library/office/… Commented May 13, 2014 at 17:21

1 Answer 1

3

I have found that a google search for "microsoft interop " leads me very quickly to the right set of pages. In your case I did "microsoft interop outlook getdefaultfolder" which led me to MSDN's NameSpaceClass.GetDefaultFolder Method page which led me (after a few clicks) to the Items Members page.

I use the same search technique for all MS Office apps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.