环顾四周,找不到满意的答案。有谁知道如何使用 Python 从 Outlook 解析 .msg 文件?
我尝试过使用 mimetools 和 email.parser,但没有成功。非常感谢您的帮助!
最佳答案
这对我有用:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\test_msg.msg")
print msg.SenderName
print msg.SenderEmailAddress
print msg.SentOn
print msg.To
print msg.CC
print msg.BCC
print msg.Subject
print msg.Body
count_attachments = msg.Attachments.Count
if count_attachments > 0:
for item in range(count_attachments):
print msg.Attachments.Item(item + 1).Filename
del outlook, msg
请参阅以下帖子,了解有关从收件人、抄送和密件抄送属性访问电子邮件地址的方法,而不仅仅是名称(例如“John Doe”) - enter link description here
关于python - 用python解析outlook .msg文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26322255/