【发布时间】:2017-12-30 21:42:58
【问题描述】:
我是 python 新手。我想在 python 中读取 .MSG 文件并进行解析 目前我正在尝试以下代码
def read_mail(msg):
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("IMAP")
msg=outlook.OpenSharedItem(msg)
mail_list=[];
mail_list.append(msg.SenderName)
mail_list.append(msg.SenderEmailAddress)
mail_list.append(msg.SentOn)
mail_list.append(msg.Subject)
mail_list.append(msg.Body)
del outlook, msg
return mail_list
msg=("samples\\UseCase1.msg")
read_mail(msg)
我遇到这样的错误
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2146959355, 'Server execution failed', None, None)
【问题讨论】: