【发布时间】:2021-08-24 19:40:46
【问题描述】:
上下文:我的 Oulook 收件箱中有 100 封主题为 'Target subject <something>' 的电子邮件,我想将它们全部移到另一个文件夹中,比如 'MyFolder'。这是我的 python (version=3.9.6) 程序:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
root_folder = outlook.Folders.Item(1)
inbox = outlook.GetDefaultFolder(6)
myfolder = root_folder.Folders['MyFolder']
messages = inbox.Items
for message in messages:
if 'Target subject' in message.Subject:
message.Move(myfolder)
问题:程序运行时没有抛出任何错误,但只移动了预期的 100 封电子邮件中的 20 封。如果我多次运行该程序,它可以实现一次移动 20 个。
尝试:我在windows API documentation 中进行了搜索,但没有发现任何有用的信息。
问题:知道是什么导致了这种限制以及如何避免它吗?
谢谢!
【问题讨论】:
标签: python-3.x email outlook move win32com