Email Format Support#
Docling converts email files through the EmailDocumentBackend, which handles the InputFormat.EMAIL enum value using the SimplePipeline.
Current support: .eml only#
The only registered extension for InputFormat.EMAIL is "eml" , mapped to MIME type message/rfc822 . Parsing is performed by the mail-parser library (installed via the format-email optional extra — see Installation).
What the backend extracts :
- Subject → document title
- From / To / Date → plain-text items
- Body → paragraph-split plain text, or HTML passed through
HTMLDocumentBackendand then re-split
Attachments are not processed — neither extracted nor converted. Pagination is not supported .
Body parsing priority :
text_plainparts (preferred)text_htmlparts (converted viaHTMLDocumentBackend)- Raw
bodyfallback
The mail-parser import is lazily guarded — a missing package raises a clear ImportError with an install hint at instantiation time rather than crashing on module import .
.msg (Outlook) format: proposed but not merged#
.msg files use the OLE2/CFBF binary container format and cannot be parsed by mail-parser. As of the current codebase, .msg is not registered in FormatToExtensions or FormatToMimeType , and attempting to convert one raises a File format not allowed error.
PR #3716 proposed .msg support by:
- Registering
"msg"/application/vnd.ms-outlookin the format tables - Detecting the OLE2/CFBF magic bytes and dispatching to
extract-msg(added to theformat-emailextra) - Mapping subject/sender/recipients/date/body into the same
DoclingDocumentshape as.eml - Introducing
EmailBackendOptions(include_attachments=False)to optionally surface attachment metadata (filename, media type, size) without inlining payloads
PR #3716 was closed without merging. The README historically listed .msg as supported, which was inaccurate . If .msg support is needed, track the linked issue #3712 for future work.
Installation#
# Required for .eml parsing
pip install 'docling[format-email]'
The format-email extra pulls in mail-parser>=4.1.4,<5.0.0 and beautifulsoup4 (via format-html) . extract-msg is not in the current extra — it would only apply once .msg support lands.
Key files#
| File | Purpose |
|---|---|
docling/backend/email_backend.py | EmailDocumentBackend — full parsing logic |
docling/datamodel/base_models.py | FormatToExtensions / FormatToMimeType registrations |
pyproject.toml | format-email extra definition |
| PR #3716 | Closed proposal for .msg + attachment listing |
| Issue #3712 | Tracking issue for .msg support |