Pythoncom-如何收听Outlook外发邮件?

时间:2018-06-28 16:25:46

标签: python outlook pythoncom outgoing-mail

此刻,我正在使用以下代码从Python侦听Outlook中的传入消息。

如何处理Outlook中的外发邮件?

import win32com.client
import pythoncom

class Handler_Class(object):

senders = ['blabla@gmail.com']

def OnNewMailEx(self, receivedItemsIDs):
    # RecrivedItemIDs is a collection of mail IDs separated by a ",".
    # You know, sometimes more than 1 mail is received at the same moment.

    for ID in receivedItemsIDs.split(","):
        mail = outlook.Session.GetItemFromID(ID)
        subject = mail.Subject



outlook = win32com.client.DispatchWithEvents("Outlook.Application",Handler_Class)

# an infinite loop that waits for event
pythoncom.PumpMessages()

0 个答案:

没有答案