我正在使用 win32com.client 检查电子邮件的附件,如果有附件,它会使用附件文件名填充 wxpython 列表框。仅当电子邮件名称不包含空格时才有效。如果文件名中有空格,它将用“%20”替换它们,这会导致错误。我尝试使用urllib.unquote()
,但没有奏效。有人能帮忙吗?
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)
回溯(最近一次通话最后):文件“C:\Users\onp1ldy\eclipse-workspace\WOrk\EmailParser.py”,第 137 行,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'。文件可能已经打开,或者您没有打开它的权限。\n\n要检查您的权限,对-单击文件夹,然后单击属性。",无,0,-2147287038),无)