简体   繁体   中英

How to read incoming emails with pywin32 module in python

I am trying to make a python script which reads incoming email on outlook using pywin32 library. I am having trouble finding a way to keep reading incoming emails. At first I thought of writing an infinite loop and getting all unread emails, but that does not seem very efficient. I would appreciate some help

You can handle the NewMailEx event of the Application class. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. Use the Entry ID represented by the EntryIDCollection string to call the NameSpace.GetItemFromID method and process the item. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem , MeetingItem , or SharingItem .

Also you may consider handling the ItemAdd event on the Inbox folder in Outlook.

Read more about possible ways in the following series of articles:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM