如何使用 python 中的 win32com.client 模块从 .MSG 文件获取发件人电子邮件地址?
这是我到目前为止所拥有的:
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
for path, dirs, files in os.walk('.'):
for filename in files:
filename_no_ext, ext = os.path.splitext(filename)
if ext.lower() in ['.msg']:
try:
msg = outlook.OpenSharedItem(os.path.join(os.path.abspath(path), filename))
except Exception as x:
print >>sys.stderr, filename
print >>sys.stderr, x
continue
最佳答案
使用MailItem.SenderEmailAddress属性(property)。
关于Python 2.7 - Outlook Win32com.client 无法从 .msg 获取发件人的实际电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52626826/