Reputation: 411
I’m using a python package called win32com
to directly access and scrape the inboxes from Outlook. As the Outlook application is setup to have multiple email accounts, I’ve had to adapt my code to read messages from multiple email accounts. However, the messages contains calendar invites and I just want email messages to be scraped. Is there a way to filter the messages based on type?
Outlook = client.Dispatch(“Outlook.Application”).GetNameSpace(“MAPI”)
Messages = outlook.Folders(“[email protected]).Folders(“Inbox”)
For msg in messages:
#Do Something
Upvotes: 0
Views: 656
Reputation: 8077
Yes, you need to check if the object is of type OlObjectClass.olMail
, which is represented by value 43
. You can check all enumerations here.
Outlook = client.Dispatch(“Outlook.Application”).GetNameSpace(“MAPI”)
Messages = outlook.Folders(“[email protected]).Folders(“Inbox”)
for msg in messages:
if msg.Class == 43: # OlObjectClass.olMail
#Do Something
Upvotes: 1