SaveasFile Outlook邮件函数给我错误给予:Acess拒绝您没有此操作的许可
所以我想做的基本上就是保存附件。这是在特定的电子邮件上。上面有一个特定的日期,但是当我尝试执行 SaveasFile 方法时。我收到一个错误。 (-2147352567, '发生异常。', (4096, 'Microsoft Outlook', '无法保存附件。您无权执行此操作。', 无, 0, -2147024891), 无)
我的基本代码如下。
path_zip = "../Query/Full_prod" #localizacao onde fica a file zipada
outlook = win32com.client.Dispatch('outlook.application')# Abre o outlook
mapi = outlook.GetNamespace("MAPI") #Call do outlook
root_folder = mapi.Folders.Item(1) # Folder inicial do seu outlook
subfolder = root_folder.Folders['Eventtracks bot prod'] # Subfolder do local arquivado
messages = subfolder.Items
def SalvaAnexo(): # Retorna os anexos que nao estao sendo salvos.
created_files = os.listdir(f'{path_zip}/Marco') #Mes desejado
created_files = [i[3:5] for i in created_files] # Dias ja criados
for message in messages:
if "2022-03" in message.Subject: # Filtro para diminuir tamanho do loop
attachments = message.Attachments
attachment = attachments.Item(1) #Pegando o attachment
dias_email = str(message.Subject.split("-")[-1]) #Dia dos attachment
if dias_email not in created_files:
print(dias_email)
attachment.SaveasFile(r'E:\csms\Query\Full_prod')
值得注意的是,之前我在我的 C: 驱动器上使用了这个功能,这个小功能运行得很好。将不胜感激一些帮助。
So what am i trying to do is basically, save an attachment. That is on a specific email. With a specific date on it, but when i try to execute the SaveasFile method. I get an error. (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'Not possible to save attachment. You dont have the permission to execute this operation.', None, 0, -2147024891), None)
My base code is as follows.
path_zip = "../Query/Full_prod" #localizacao onde fica a file zipada
outlook = win32com.client.Dispatch('outlook.application')# Abre o outlook
mapi = outlook.GetNamespace("MAPI") #Call do outlook
root_folder = mapi.Folders.Item(1) # Folder inicial do seu outlook
subfolder = root_folder.Folders['Eventtracks bot prod'] # Subfolder do local arquivado
messages = subfolder.Items
def SalvaAnexo(): # Retorna os anexos que nao estao sendo salvos.
created_files = os.listdir(f'{path_zip}/Marco') #Mes desejado
created_files = [i[3:5] for i in created_files] # Dias ja criados
for message in messages:
if "2022-03" in message.Subject: # Filtro para diminuir tamanho do loop
attachments = message.Attachments
attachment = attachments.Item(1) #Pegando o attachment
dias_email = str(message.Subject.split("-")[-1]) #Dia dos attachment
if dias_email not in created_files:
print(dias_email)
attachment.SaveasFile(r'E:\csms\Query\Full_prod')
Is worth noting that before hand i used this function on my C: drive and this little function worked perfectly. Would apreciate some help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论