我正在循环浏览大型邮箱中的邮件,以将附件保存在本地文件夹中。保存大量附件后,出现以下错误:您的服务器管理员限制了您可以同时打开的项目数。
有没有办法防止这种情况?保存后,我尝试将附件设置为无,使用 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)