skillfed

RTFDE

A library for extracting HTML content from RTF encapsulated HTML as commonly found in the exchange MSG email format.

rtfde v0.1.2.2 6.6M downloads/30d#1,886 on PyPI8
Copyleft license AGING released

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 rtfde

uv

uv add rtfde

poetry

poetry add rtfde

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)Operating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Communications :: Email :: FiltersTopic :: Text Processing :: FiltersTopic :: Text Processing :: Markup :: HTML

Tags

rtf de-encapsulationextract html from rtfmsg file content extractionrtf to html converteremail body decodingexchange msg parserrtf deencapsulator
email-processingrtf-parsingmsg-extraction

More HTML packages