[英]Read contents of a selected Outlook e-mail using python
I have this simple piece of code that reads the content of the last e-mail in my inbox.我有一段简单的代码,用于读取收件箱中最后一封电子邮件的内容。
How can I do the same for e-mail I click on/highlight within Outlook?如何对在 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)
Simply use ActiveExplorer().Selection(1)只需使用ActiveExplorer().Selection(1)
Example例子
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.