我正在尝试遍历我的电子邮箱并查找具有特定主题的电子邮件。我正在使用:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
# the inbox. You can change that number to reference
# any other folder
messages = inbox.Items
message = messages.GetLast()
print(message)
body_content = message.body
print body_content
有谁知道我在哪里可以找到这方面的文档。我想使用 GetAll() 函数然后按主题或 getSubject() 函数进行过滤,但我根本找不到这方面的文档。任何帮助都会很棒。
最佳答案
我发现在 google 上搜索“microsoft interop”可以很快找到正确的页面集。在你的情况下,我做了“microsoft interop outlook getdefaultfolder”,这让我找到了 MSDN 的 NameSpaceClass.GetDefaultFolder Method将我(点击几下)引导到 Items Members 的页面页。
我对所有 MS Office 应用程序使用相同的搜索技术。
关于Python win32com.client 和 outlook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23635967/