使用python在Outlook中阅读邮件中的附加邮件
我想知道我们如何在emailfor Microsoft outlook中下载、获取或打印电子邮件附件。以下是我的代码,用于查找特定主题的常规附件。同样的方式,我想收到附加的电子邮件以及 导入win32com.client使用python在Outlook中阅读邮件中的附加邮件,python,email,outlook,automation,email-attachments,Python,Email,Outlook,Automation,Email Attachments,我想知道我们如何在emailfor Microsoft outlook中下载、获取或打印电子邮件附件。以下是我的代码,用于查找特定主题的常规附件。同样的方式,我想收到附加的电子邮件以及 导入win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox = outlook.GetDefaultFolder(6)
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
path = os.path.expanduser("~/Desktop/ok")
messages = inbox.Items
for message in messages:
if message.subject == 'WFH Internet Charge Reimbursement':#'FW: Canada Goose - Spend Emails':
print("Found message")
print(message.Body)
print(message.Senton.date())
attachments = message.Attachments
attachment = attachments.Item(1)
for attachment in message.Attachments:
attachment.SaveAsFile(os.path.join(path, str(attachment)))
if message.Subject == 'WFH Internet Charge Reimbursement' and message.Unread:
message.Unread = False
break