Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top