用python解析outlook .msg文件 [英] Parsing outlook .msg files with python

查看:52
本文介绍了用python解析outlook .msg文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环顾四周,没有找到满意的答案.有谁知道如何使用 Python 解析 Outlook 中的 .msg 文件?

Looked around and couldn't find a satisfactory answer. Does anyone know how to parse .msg files from outlook with Python?

我尝试过使用 mimetools 和 email.parser,但没有成功.将不胜感激!

I've tried using mimetools and email.parser with no luck. Help would be greatly appreciated!

推荐答案

这对我有用:

import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:	est_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") - 在此处输入链接描述

Please refer to the following post regarding methods to access email addresses and not just the names (ex. "John Doe") from the To, CC and BCC properties - enter link description here

这篇关于用python解析outlook .msg文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆