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()。Aspose.Email FOSS 使用单个 pip install aspose-email-foss 命令进行安装。该软件包没有任何外部依赖,且是纯 Python。
API遵循MAPI约定:MapiMessage、MapiAttachment、MapiRecipient、MapiProperty。该库是 MIT-licensed,开源,并接受在 GitHub 上的错误报告和贡献。
使用 pip 安装,然后将文件路径传递给 MapiMessage.from_file() 以解析 MSG 二进制格式。通过高级 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}")
从头创建 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)文件。该库还可以在 MSG 与 RFC 5322 电子邮件格式之间进行转换。
运行 pip install aspose-email-foss。需要 Python 3.10 或更高版本。
不能直接。使用 MapiMessage.from_email_message() 将 EmailMessage 对象(由 EML 内容构造)转换。
是的。使用 MapiMessage.create(subject, body) 构建新消息,然后在保存之前添加收件人和附件。
每个 MapiMessage 实例都是独立的。对不同实例的并发操作是安全的。
Aspose.Email-FOSS-for-Python. - 该库采用 MIT 许可证,并托管在 GitHub,地址为 aspose-email-foss/Aspose.Email-FOSS-for-Python。