Aspose.Email FOSS for Python 是一个 100% 免费、MIT 许可证的库,允许您完全在 Python 中读取和写入 Microsoft Outlook MSG 文件,无需 Microsoft Office、COM 自动化,也不需要专有运行时。它提供了一个基于 MAPI 概念(MapiMessage、MapiAttachment、MapiRecipient)的简洁公共 API,并由用纯 Python 编写的内置 CFB(Compound File Binary)解析器支持。
使用 pip install aspose-email-foss 从 PyPI 安装。需要 Python 3.10 或更高版本。
该库适用于电子邮件归档脚本、合规流水线、迁移工具以及任何需要在没有 Microsoft Office 依赖的情况下解析或生成 Outlook MSG 文件的服务器端工作流。欲获取更高级的功能,请考虑 Aspose.Email for Python。
MapiMessage.from_file()打开任何Outlook MSG 文件.iter_attachments_info() 来访问附加文件的元数据或双重数据.MapiMessage.create()从头开始构建新的MSG文件.save()写入磁盘,或用 to_bytes().获取字节.to_email_message() 和 from_email_message() 在 MSG 与 RFC 5322 之间进行转化.Aspose.Email FOSS 使用单个 pip install aspose-email-foss 命令进行安装。该软件包没有外部依赖,且是纯 Python。
该 API 遵循 MAPI 约定:MapiMessage,MapiAttachment,MapiRecipient,MapiProperty。该库采用 MIT 许可证,开源,并接受在 GitHub 上的错误报告和贡献。
使用 pip 安装,然后传递一个文件路径到 MapiMessage.from_file() 解析 MSG 二进制格式.通过高层API访问主题,体和附件.
pip install aspose-email-fossfrom aspose.email_foss.msg import MapiMessage
msg = MapiMessage.from_file("message.msg")
print(f"Subject: {msg.subject}")
print(f"Body: {msg.body}")
for att in msg.iter_attachments_info():
print(f"Attachment: {att.storage_name}")
创建MSG文件从头开始,添加接收者和附件,并保存到磁盘上.
from aspose.email_foss.msg import MapiMessage
msg = MapiMessage.create("Meeting Notes", "Please review attached.")
msg.add_recipient("alice@example.com", display_name="Alice")
with open("notes.pdf", "rb") as f:
msg.add_attachment("notes.pdf", f.read(), mime_type="application/pdf")
msg.save("output.msg")
它是一个免费的,获得MIT许可证的Python库来读取和写入Microsoft Outlook MSG文件而无需 Microsoft Office,COM自动化或任何专有运行时间.
在CFB v3和v4格式的MSG (Outlook) 文件.图书馆还可以在MS G和RFC 5322电子邮件格态之间转换.
运行 pip install aspose-email-foss.需要 Python 3.10 或更新版本.
不是直接.使用MapiMessage.from_email_message() 来从 EML 内容构建的 EmailMessage 对象转换.
是的. 使用MapiMessage.create(subject, body)创建一个新消息,然后在保存之前添加接收者和附件.
每个 MapiMessage 实例都是独立的.对单独实验进行并发操作是安全的
该库是MIT许可,并托管在GitHub的 aspose-email-foss/Aspose.Email-FOSS-for-Python.