Opening files with spaces with outlook.OpenSharedItem is giving error
Opening files with spaces with outlook.OpenSharedItem is giving error I got the following code: import win32com.client import os directory = "C:/Users/mypath/" for filename in os.listdir(directory): _, file_extension = os.path.splitext(filename) if file_extension == ".msg": print(filename) outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") msg = outlook.OpenSharedItem(directory + filename) att=msg.Attachments for i in att: i.SaveAsFile(os.path.join(directory, i.FileName)) del outlook, msg This code extracts the files attached to a .msg and when I run it, I got the following output: ATP-3770289.msg ATP-5126209.msg ATP-5126317.msg ATT -1937501.msg com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', "We can't open 'C://Users/omar.lopez.rubio/Desktop/admisiones/ATT%20-1937501.msg'. It's possib...
