RTFDE
A library for extracting HTML content from RTF encapsulated HTML as commonly found in the exchange MSG email format.
What it is and what it does
RTFDE is a Python library that reverses Microsoft Exchange's RTF encapsulation of email body content. When Outlook or Exchange stores HTML or plain text email bodies, they wrap them in RTF format; this library extracts the original HTML or text from that wrapper. It depends on lark (for parsing) and oletools (for RTF/OLE handling) and is designed specifically for .msg file processing.
The library handles two main tasks: extracting HTML from RTF-encapsulated HTML, and extracting plain text from RTF-encapsulated text. It fully unquotes the extracted content, which means escaped sequences (like Quoted-Printable encoding) are decoded. Known limitations include inability to integrate attachments back into HTML bodies and no support for extracting plain text from RTF-encapsulated HTML (you would use another HTML parser for that).
Use it for:
- Parse .msg email files and recover the original HTML body content instead of the RTF wrapper.
- Batch-process Exchange-exported emails to extract and re-render body content as clean HTML or text.
- Build email archival or migration tools that need to normalize RTF-wrapped content from older Outlook exports.
- Integrate with oletools-based email forensics workflows to de-encapsulate message bodies.
- Convert RTF-encapsulated plain text from .msg files back to readable text for indexing or search.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts encapsulated HTML and plain text content from RTF bodies in .msg email files, reversing the RTF encapsulation that Microsoft Exchange applies.
Yes, if you need to extract HTML or text from RTF-encapsulated .msg email bodies. The library is narrow in scope, low friction to install, and has no known vulnerabilities. The aging maintenance status and small community (8 stars) mean it is unlikely to gain new features, but the core task is stable and unlikely to require frequent updates. Suitable for production use in email processing pipelines where RTF de-encapsulation is a known requirement.
Install
rtfde on PyPI
pip
pip install rtfdeuv
uv add rtfdepoetry
poetry add rtfdeInstalling RTFDE
Before you install
Low friction: pure Python wheel with only two runtime dependencies (lark and oletools). Maintenance is aging—last release was 248 days ago and the repository has minimal activity (8 stars), but it remains archived=false and the codebase is stable for its narrow scope.
License in practice
Licensed under LGPLv3 (copyleft). You may use and modify the library freely, but any derivative work must also be distributed under LGPLv3; static linking or bundling into proprietary software requires careful legal review.
Quickstart
from RTFDE.deencapsulate import DeEncapsulator
with open('rtf_file', 'rb') as fp:
raw_rtf = fp.read()
rtf_obj = DeEncapsulator(raw_rtf)
rtf_obj.deencapsulate()
if rtf_obj.content_type == 'html':
print(rtf_obj.html)
else:
print(rtf_obj.text)
Requires Python >= 3.8. Input must be raw RTF bytes (typically from a .msg file body).
Verify before relying
- How well does de-encapsulation handle modern Exchange RTF variants and edge cases beyond the documented known issues?
- Performance characteristics with large RTF payloads or batch processing of many .msg files.
- Compatibility with oletools versions and whether oletools updates could affect behavior.
Package facts
| License | not declared (copyleft) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — lark, oletools |
| Maintenance | aging — 248 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,577,070/month — #1,886 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: rtfde-0.1.2.2-py3-none-any.whl
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
rtfparseParses Microsoft Rich Text Format (RTF)…
permissive · top 15,000 on PyPI
tnefparseDecodes Microsoft's Transport Neutral…
copyleft · top 15,000 on PyPI
extract-msgExtracts email metadata (from, to, cc, date,…
copyleft · top 5,000 on PyPI
striprtfConverts Rich Text Format (RTF) files to plain…
permissive · top 5,000 on PyPI
msg-parserParses Microsoft Outlook MSG email files,…
permissive · top 15,000 on PyPI
quotequailIdentifies and separates quoted text from…
permissive · top 15,000 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
pyth3Converts marked-up text between formats…
permissive · top 5,000 on PyPI
markdown2Converts Markdown text to HTML using a fast,…
permissive · top 5,000 on PyPI