Getting Started

Getting Started with Aspose.Email FOSS for Python

Welcome to aspose-email-foss, a free, MIT-licensed Python library for reading, creating, and writing Outlook MSG files and their underlying CFB (Compound File Binary) containers. This guide takes you from a fresh environment to working with MSG files in minutes.


Prerequisites

RequirementDetail
Python3.10 or later
Package managerpip
OSWindows, macOS, or Linux
DependenciesNone — pure Python

Installation

Install from PyPI:

pip install aspose-email-foss

Verify:

from aspose.email_foss.msg import MapiMessage
print("aspose-email-foss loaded successfully.")

See the Installation Guide for virtual-environment setup and verification.


What You Can Do

Once installed you can immediately:

  • Read MSG files with MapiMessage.from_file() — access subject, body, HTML body, headers, and recipients
  • Create MSG messages from scratch with MapiMessage.create() — set subject, body, add recipients and attachments
  • Convert between MSG and email (RFC 5322) format with to_email_message() and from_email_message()
  • Inspect low-level CFB structure with CFBReader — iterate storages, streams, and directory entries
  • Write MSG files with MapiMessage.save() or MsgWriter.write_file()
  • Handle attachments — add binary attachments or embed MSG messages as nested attachments

Quick Start

Read an MSG file and print its subject and recipients:

from aspose.email_foss.msg import MapiMessage

msg = MapiMessage.from_file("message.msg")
print(f"Subject: {msg.subject}")
print(f"Body: {msg.body[:200]}")

msg.save("copy.msg")
print("Saved copy.msg")

Next Steps