【发布时间】:2020-04-29 15:38:48
【问题描述】:
如何在 python 中从 MSG 文件中下载、保存或提取附件文件? 有很多库用于提取发件人姓名或...但提取 msg 文件不起作用。
【问题讨论】:
-
这能回答你的问题吗? Parsing outlook .msg files with python
标签: python outlook attachment email-attachments
如何在 python 中从 MSG 文件中下载、保存或提取附件文件? 有很多库用于提取发件人姓名或...但提取 msg 文件不起作用。
【问题讨论】:
标签: python outlook attachment email-attachments
要从 Outlook 的 MSG 文件中提取文件,请使用以下代码:
import win32com.client,os
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem('C:/Users/aa/test.msg')
for att in msg.Attachments:
print(att.FileName)
print(msg.Attachments.Count)
att.SaveASFile(os.path.join(save_folder, str(att.FileName))) # save_folder is that folder for save Attachments files example: C:/Users/aa/extract
完成!
【讨论】: