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 或更高版本。
该库适用于电子邮件归档脚本、合规性流水线、迁移工具以及任何需要在服务器端解析或生成 Outlook MSG 文件且不依赖 Microsoft Office 的工作流。
MapiMessage.from_file().iter_attachments_info() or access binary data.MapiMessage.create().save() or get bytes with to_bytes().to_email_message() and from_email_message().Aspose.Email FOSS installs with a single pip install aspose-email-foss command. The package has zero external dependencies and is pure Python.
The API follows MAPI conventions: MapiMessage, MapiAttachment, MapiRecipient, MapiProperty. The library is MIT-licensed, open-source, and accepts bug reports and contributions on GitHub.
Install with pip, then pass a file path to MapiMessage.from_file() to parse the MSG binary format. Access subject, body, and attachments through the high-level API.
pip install aspose-email-foss
from 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}")
Create MSG files from scratch, add recipients and attachments, and save to disk.
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")
It is a free, MIT-licensed Python library for reading and writing Microsoft Outlook MSG files without requiring Microsoft Office, COM automation, or any proprietary runtime.
MSG (Outlook) files in CFB v3 and v4 format. The library can also convert between MSG and RFC 5322 email format.
Run pip install aspose-email-foss. Requires Python 3.10 or later.
Not directly. Use MapiMessage.from_email_message() to convert from an EmailMessage object constructed from EML content.
Yes. Use MapiMessage.create(subject, body) to build a new message, then add recipients and attachments before saving.
Each MapiMessage instance is independent. Concurrent operations on separate instances are safe.
The library is MIT-licensed and hosted on GitHub at aspose-email-foss/Aspose.Email-FOSS-for-Python.