【发布时间】:2020-09-28 04:49:09
【问题描述】:
我想下载来自我的 Outlook 收件箱的特定附件。我想根据主题和发送日期过滤这些电子邮件。
这就是我正在做的:
Outlook = win32com.client.Dispatch("Outlook.Application")
olNs = Outlook.GetNamespace("MAPI")
Inbox = olNs.GetDefaultFolder(6)
Filter = "[Subject] = 'Important Report' And [SenderEmailAddress] = 'data@cool.com' And [SentOn]
> '9/26/2020 08:00 AM'"
Items = Inbox.Items.Restrict(Filter)
Item = Items.GetFirst()
for attachment in Item.Attachments:
print(attachment.FileName)
attachment.SaveAsFile(r"C:\Users\lynnette\Desktop\file.xls")
目前,它正在使用 [SentOn] 进行过滤,但是,我使用的是特定日期。我想根据当前日期进行过滤。我研究了 Items.Restrict,但找不到当前日期过滤器。
感谢任何帮助
【问题讨论】:
标签: python vba email outlook automation