【发布时间】:2020-10-06 05:37:16
【问题描述】:
当我使用win32com 访问outlook 2013 时,运行代码后我的outlook 明显变慢。以下是我的代码:
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
# the inbox. You can change that number to reference
# any other folder
emails = outlook.GetDefaultFolder(6).Folders['xyz'].Folders['abc'].Items
如果预先打开 Outlook,有时我会收到 com_error: (-2146959355, 'Server execution failed', None, None) 运行代码。我将不得不重新启动 Outlook 并重置我的 python 环境以恢复正常。阅读邮件后是否需要在outlook中进行任何设置或任何特殊的python操作?
最好的问候, 杰里米
【问题讨论】:
-
您是否有理由在第 2 行声明收件箱,然后在第 5 行不使用它?我的直接想法是你的泄漏对象......
-
您曾经退出过 win32com 应用程序吗?如果它仍然与计算机上的其他程序一起运行,它会占用内存/其他资源并使您原来的 Outlook 速度变慢。
-
@Evgeny - Outlook 是一个单例,任何时候只有一个实例运行。检查任务管理器
-
那是你的完整代码吗?您如何处理电子邮件集合?