0

I am using win32com.client to check an email for attachements, if there is an attachment it populates a wxpython listbox with the attachment file name(s). It only works if the email name does not contain spaces. If there are spaces in the file name, it replaces them with a "%20" which results in an error. I tried using urllib.unquote() but that did not work. Can anyone help with this?

def onListBox(self, event):
        outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
        self.email = event.GetEventObject().GetStringSelection()
        msg2 = outlook.OpenSharedItem(self.emailLocale + self.email)
        att=msg2.Attachments
        print
        if len(att):
            attachList = [i.FileName for i in att]
            self.attachList.Set(attachList)

Traceback (most recent call last): File "C:\Users\onp1ldy\eclipse-workspace\WOrk\EmailParser.py", line 137, in onListBox msg2 = outlook.OpenSharedItem(urllib.unquote(self.emailLocale + self.email).decode('utf8')) File "", line 2, in OpenSharedItem pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, u'Microsoft Outlook', u"We can't open 'C://Users/onp1ldy/Desktop/emails/emails_sent/Canceled%20%20skype.msg'. It's possible the file is already open, or you don't have permission to open it.\n\nTo check your permissions, right-click the file folder, then click Properties.", None, 0, -2147287038), None)

mickNeill
  • 346
  • 5
  • 22

0 Answers0