Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python在Outlook中阅读邮件中的附加邮件_Python_Email_Outlook_Automation_Email Attachments - Fatal编程技术网

使用python在Outlook中阅读邮件中的附加邮件

使用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)

我想知道我们如何在emailfor 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