0
:win32com.client.DispatchWithEvents私は次のコードで同時に2つの別々の受信トレイにOnItemAddイベントをリッスンしようとしています
class Handler_Class():
def OnItemAdd(self, mail):
#Check if the item is of the MailItem type
if mail.Class==43:
print(mail.Subject, " - ", mail.Parent.FolderPath)
inboxes = ["inbox1", "inbox2"]
for inbox in inboxes:
items = win32com.client.DispatchEx("Outlook.Application").GetNamespace("MAPI").Folders[inbox].Folders["Inbox"].Items
win32com.client.DispatchWithEvents(items, Handler_Class)
print(datetime.now(),"Ready to pump")
pythoncom.PumpMessages()
pythoncom.PumpMessages()しかし、動作していないようです。受信トレイのアイテムを1つだけリスンするようにコードをリファクタリングすると、機能します。
これを解決する方法はありますか?