【问题标题】:Python win32com.client and outlookPython win32com.client 和 Outlook
【发布时间】:2014-05-13 15:51:47
【问题描述】:

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

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() 函数,但我根本找不到这方面的文档。任何帮助都会很棒。

【问题讨论】:

  • Python 非常好的自我文档在这里不会帮助你。去找你正在使用的 COM 对象的文档,他们通常有很好看的帮助文件。
  • 我在哪里可以找到它?我看起来没有运气

标签: python win32com


【解决方案1】:

我发现在谷歌上搜索“microsoft interop”会很快引导我找到正确的页面集。在您的情况下,我执行了“microsoft interop outlook getdefaultfolder”,这使我进入了 MSDN 的 NameSpaceClass.GetDefaultFolder Method 页面,该页面将我(单击几下后)带到了 Items Members 页面。

我对所有 MS Office 应用都使用相同的搜索技术。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-19
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    相关资源
    最近更新 更多