0
我试图使用win32模块进行python并获取我的电子邮件正文。然而,无论何时我试图获得它,我都会遇到任何电子邮件正文的错误。我能够得到消息subject/timerecieved/etc但我似乎无法得到身体。Python Win32无法读取Outlook电子邮件正文的
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.Items
message = messages.GetLast()
body_content = message.body
---------------------------------------------------------------------------
com_error Traceback (most recent call last)
<ipython-input-41-bdd6c5734297> in <module>()
1 messages = inbox.Items
2 message = messages.GetLast()
----> 3 body_content = message.body#.encode('ascii', 'ignore').decode('ascii')
4 #print (body_content)
C:\Users\e659383\Documents\portableapps\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\win32com\client\dynamic.py in __getattr__(self, attr)
509 debug_attr_print("Getting property Id 0x%x from OLE object" % retEntry.dispid)
510 try:
--> 511 ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
512 except pythoncom.com_error as details:
513 if details.hresult in ERRORS_BAD_CONTEXT:
com_error: (-2147467259, 'Unspecified error', None, None)
我得到同样的错误任何电子邮件我试图让身体。
不幸的是我还收到了同样的错误。 – Neil
你有杀毒软件吗? -2147467259转换为错误代码:0x80004005。这可能是由防病毒脚本阻止功能导致的。 –
嗯,我们确实安装了Mcaffee。似乎奇怪的是,它可以专门阻止获取消息的正文。但我想这可能是有道理的,因为我创建了一个快速的VB脚本来尝试获取消息,它也不会工作... – Neil