extract-msg
Extracts emails and attachments saved in Microsoft Outlook's .msg files
What it is and what it does
extract-msg is a Python library and command-line tool that parses Microsoft Outlook .msg files and extracts their structured email data and attachments. It automates retrieval of standard email fields (from, to, cc, date, subject, body) and saves attachments to disk or other formats. The package handles OLE2 file parsing, Outlook's Extended MAPI property encoding, RTF decompression, and character set conversion through its runtime dependencies including olefile, compressed-rtf, RTFDE, ebcdic, beautifulsoup4, tzlocal, and red-black-tree-mod.
You can use it as a standalone CLI tool to batch-process .msg files into organized folder structures, or import it into Python code to programmatically read and transform Outlook messages. It supports output to plain text, HTML, PDF, RTF, raw, and JSON formats, with options to handle embedded messages, hidden attachments, and character set conversion. The package is actively maintained and supports Python 3.8 and above.
Use it for:
- Batch extract emails and attachments from Outlook .msg files for archival or migration
- Convert Outlook messages to HTML or PDF for document management or compliance workflows
- Programmatically parse .msg files in a data pipeline to index email metadata or extract structured content
- Recover email data from .msg files for forensic analysis or email recovery scenarios
- Automate attachment extraction from a folder of .msg files with filtering by attachment type or hidden status
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts email metadata (from, to, cc, date, subject, body) and attachments from Microsoft Outlook .msg files, with support for multiple output formats including HTML, PDF, RTF, and JSON.
Yes, if you need to parse Outlook .msg files. The package is actively maintained, has low install friction, and offers both CLI and library interfaces. However, note the GPL copyleft license—verify compatibility with your project's licensing before use in proprietary software.
Install
extract-msg on PyPI
pip
pip install extract-msguv
uv add extract-msgpoetry
poetry add extract-msgInstalling extract-msg
Before you install
Low install friction with a pure-wheel distribution. Actively maintained with a recent release and 852 repository stars. Requires Python 3.8 or above.
License in practice
Licensed under GPL (copyleft). Use in proprietary software requires careful review of licensing obligations, as copyleft terms may require derivative works to be open-source.
Quickstart
pip install extract-msg
import extract_msg
msg = extract_msg.openMsg("path/to/file.msg")
# Access msg.from_, msg.to, msg.cc, msg.date, msg.subject, msg.body
# Or from command line:
# python -m extract_msg example.msg
Requires Python 3.8 or above.
Verify before relying
- Whether all output formats (HTML, PDF, RTF, JSON) are equally well-supported or have known limitations
- Performance characteristics when processing large .msg files or batch extraction scenarios
- Compatibility with .msg files from different Outlook versions or edge cases in MAPI property structure
Package facts
| License | GPL (copyleft) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — olefile, tzlocal, compressed-rtf, ebcdic, beautifulsoup4, RTFDE, red-black-tree-mod |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,184,387/month — #1,774 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: extract_msg-0.56.1-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
mail-parserParses raw email messages into structured…
permissive · top 5,000 on PyPI
python-oxmsgParses Outlook MSG files to extract email…
permissive · top 5,000 on PyPI
tnefparseDecodes Microsoft's Transport Neutral…
copyleft · top 15,000 on PyPI
RTFDEExtracts encapsulated HTML and plain text…
copyleft · top 5,000 on PyPI
rtfparseParses Microsoft Rich Text Format (RTF)…
permissive · top 15,000 on PyPI
msg-parserParses Microsoft Outlook MSG email files,…
permissive · top 15,000 on PyPI
eml-parserParses EML (email) files and extracts…
agpl · top 15,000 on PyPI
emailsBuild and send HTML and plain-text emails with…
permissive · top 15,000 on PyPI
imap-toolsA high-level Python library for IMAP email…
permissive · top 15,000 on PyPI
redmailRedmail simplifies sending emails with Python…
permissive · top 15,000 on PyPI