使用python在Outlook中的邮件中读取附件邮件

问题描述

我想知道如何才能在Microsoft Outlook的电子邮件中下载或获取或打印电子邮件附件。这是我的代码,用于查找特定主题的正常附件。同样,我也想接收附件的电子邮件

导入win32com.client

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)