繁体   English   中英

如何使用win32com.mapi从python中的outlook获取新的email?

[英]how to use win32com.mapi get new email from outlook in python?

我想在新的 email 变成 outlook 时收到消息。我尝试使用 python。

我可以找到那个文件夹,但找不到获取新 email 号码的方法。

 import win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") accounts = win32com.client.Dispatch("Outlook.Application").Session.Accounts; inbox = outlook.Folders(accounts[0].DeliveryStore.DisplayName) for obj in inbox.Folders: #how to know how many new email in this dir? try: if hasattr(obj, "__str__"): dirName = obj.__str__() #as some new email in this obj. for message in obj.items: # how to know this email is not be read? subject = sender = '' if hasattr(message, "Subject"): subject = message.Subject if hasattr(message, "SenderName"): sender = message.SenderName print(sender, subject) except Exception as e: print(f"i:{obj.__str__()}")

我在哪里可以学习 win32com.mapi? 我想知道我可以在 mapi 中使用什么功能。

请给我一些信息~非常感谢!

您在寻找未读消息吗? 使用MAPIFolder.Items.Restrict("[Unread] = true")检索应用了限制的Items集合。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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