我不明白如何使用 Python 解析来自 Outlook 的突出显示(选定)邮件?
我有这个代码,但它适用于上一封邮件。
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items
message = messages.GetLast()
body_content = message.body
print (body_content)
需要解析突出显示的邮件的发件人电子邮件地址吗?
最佳答案
应该
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
messages = outlook.ActiveExplorer().Selection
message = messages(1)
try:
if message.SenderEmailType == "EX":
print("EX: ", message.Sender.GetExchangeUser().PrimarySmtpAddress)
else:
if message.SenderEmailType == "SMTP":
print("SMTP: ", message.SenderEmailAddress)
except Exception as e:
print(e)
关于python - 如何使用Python从outlook获取突出显示(选定)的邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54418300/