Python win32com.client 和 outlook

标签 python win32com

我正在尝试遍历我的电子邮箱并查找具有特定主题的电子邮件。我正在使用:

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/

相关文章:

python - 如何将数据拟合到温度/热曲线上?

php - 从 PHP 脚本调用 Python 脚本/C++exe

Python Excel COM 互操作 : Force headless mode and prevent user inputs

python - 如何使用 Python win32com 中的所有默认加载项运行 excel

Microsoft Excel WorksheetFunction 上的 Python win32com

python - 检索 Excel 工作簿连接属性

python - 在 Pandas 中获得滚动平均值的最快方法?

python - pandas 填充缺失值错误?

python - Pandas:当列中的所有数据均为 NaN 时,从多级索引中删除索引条目(及其所有行)

python win32 COM关闭excel工作簿