【问题标题】:Read contents of a selected Outlook e-mail using python使用 python 读取选定 Outlook 电子邮件的内容
【发布时间】:2019-07-26 07:24:22
【问题描述】:

我有一段简单的代码可以读取我收件箱中最后一封电子邮件的内容。

如何对在 Outlook 中单击/突出显示的电子邮件执行相同操作?

import win32com.client

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

inbox = outlook.GetDefaultFolder(6) 
messages = inbox.Items
message = messages.GetLast()
print(message.body) 

【问题讨论】:

    标签: python email outlook win32com


    【解决方案1】:

    只需使用 ActiveExplorer().Selection(1)

    例子

    import win32com.client
    
    outlook = win32com.client.Dispatch("Outlook.Application")
    messages = outlook.ActiveExplorer().Selection
    message = messages(1)
    print(message.body)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-13
      • 2011-07-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      • 2015-11-07
      • 2018-04-26
      • 2020-05-30
      相关资源
      最近更新 更多