[英]Read contents of a selected Outlook e-mail using python
我有一段简单的代码,用于读取收件箱中最后一封电子邮件的内容。
如何对在 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)
只需使用ActiveExplorer().Selection(1)
例子
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
messages = outlook.ActiveExplorer().Selection
message = messages(1)
print(message.body)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.