1

目前我正在使用下面的代码来收听来自 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()
4

0 回答 0