win32com outlook 客户端和保存附件时出错(您的服务器管理员限制了您可以同时打开的项目数)
Error with win32com outlook client and saving attachments (Your server administrator has limited the number of items you can opensimultaneously)
我正在循环浏览大型邮箱中的邮件,以将附件保存在本地文件夹中。保存大量附件后,出现如下错误:
您的服务器管理员限制了您可以同时打开的项目数。
有什么办法可以避免这种情况吗?我尝试在保存后将附件设置为 None,使用 message.Close(0/1) 关闭电子邮件并更改共享邮箱的缓存设置。
for message in list(messages):
for attachment in message.Attachments:
attachment_name = str(attachment)
if re.search('(.xlsx|.csv|.xls)',attachment_name):
if attachment_name in attachment_list:
no = no+1
attachment_name = str(no) + ' ' + attachment_name
attachment.SaveASFile(path+ '\' + attachment_name)
print(attachment_name, 'saved from mail', message)
attachment_list.append(attachment_name)
else:
attachment.SaveASFile(path+ '\' + attachment_name)
print(attachment_name, 'saved from mail', message)
attachment_list.append(attachment_name)
attachment.Close(1)
else:
pass
message.Close(1)
Your server administrator has limited the number of items you can opensimultaneously.
这是一个很好的指标,表明您在内存中保留了多个 COM 对象 运行,即使您已完成对它们的使用。我建议及时释放所有底层对象。
Python 当不再有对对象的引用时,对象被释放。
Rebinding obj to None would decrease the reference count to the object, and so would del obj. In both cases, the instance would be cleared if obj was the last reference to it.
The difference then is how you can use obj afterwards. Rebinding retains the variable (it is now bound to None), del removes it altogether and you'd get a NameError. What you pick is your choice, it won't have influence on how the instance is cleared from memory.
在 页面上阅读更多相关信息。
我正在循环浏览大型邮箱中的邮件,以将附件保存在本地文件夹中。保存大量附件后,出现如下错误: 您的服务器管理员限制了您可以同时打开的项目数。
有什么办法可以避免这种情况吗?我尝试在保存后将附件设置为 None,使用 message.Close(0/1) 关闭电子邮件并更改共享邮箱的缓存设置。
for message in list(messages):
for attachment in message.Attachments:
attachment_name = str(attachment)
if re.search('(.xlsx|.csv|.xls)',attachment_name):
if attachment_name in attachment_list:
no = no+1
attachment_name = str(no) + ' ' + attachment_name
attachment.SaveASFile(path+ '\' + attachment_name)
print(attachment_name, 'saved from mail', message)
attachment_list.append(attachment_name)
else:
attachment.SaveASFile(path+ '\' + attachment_name)
print(attachment_name, 'saved from mail', message)
attachment_list.append(attachment_name)
attachment.Close(1)
else:
pass
message.Close(1)
Your server administrator has limited the number of items you can opensimultaneously.
这是一个很好的指标,表明您在内存中保留了多个 COM 对象 运行,即使您已完成对它们的使用。我建议及时释放所有底层对象。
Python 当不再有对对象的引用时,对象被释放。
Rebinding obj to None would decrease the reference count to the object, and so would del obj. In both cases, the instance would be cleared if obj was the last reference to it.
The difference then is how you can use obj afterwards. Rebinding retains the variable (it is now bound to None), del removes it altogether and you'd get a NameError. What you pick is your choice, it won't have influence on how the instance is cleared from memory.
在