使用Python保存特定日期的Outlook附件

2024-09-20 22:54:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道如何在此代码中添加日期以保存Outlook中的附件文件和电子邮件:例如,我想保存2020年4月20日至2020年1月1日之间找到的文件。请问你有什么想法吗

outputDir = r"C:\Users\CMhalla\Desktop\attachment"
i=0
for m in messages:
    if m.SenderEmailAddress == 'info@outlook.com':
       body_content=m.Body
       for attachment in m.Attachments:
           i=i+1
           attachment.SaveAsFile(os.path.join(outputDir,attachment.FileName + str(i)+'.xlsx'))

Tags: 文件代码infor附件attachmentif电子邮件
2条回答

换线

for m in messages:

(从我的头顶上):

for m in messages.Restrict("([ReceivedTime] <= '04/20/2020') AND ([ReceivedTime] >= '01/01/2020') AND (SenderEmailAddress = 'info@outlook.com')"):

相关问题 更多 >

    热门问题