microsoft / microsoft/markitdown

EmlConverter: add support for converting email attachments

Open
#1,662 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
186k
Forks
13.7k
Avg merge
1d 4h
Merged PRs (30d)
49

Description

Problem

PR #1633 adds EmlConverter which correctly extracts email headers and the message body. However, email attachments are not processed. A .eml file that contains an attached PDF, Word document, or image is converted to just the email body text, with no indication that attachments exist or what they contain.

For use cases like:

  • Converting an inbox export to a searchable knowledge base
  • Extracting information from automated report emails with attached spreadsheets
  • Processing compliance email archives that include attached contracts

...the body text alone is not enough. The attachments often contain the most important content.

Proposed solution

Extend EmlConverter._get_body() (or add a new _get_attachments() method) to:

  1. Detect MIME parts that are attachments (i.e., Content-Disposition: attachment)
  2. For each attachment, pass the raw bytes back through the main MarkItDown converter using the attachment filename to determine the appropriate converter
  3. Append each converted attachment to the markdown output under a ## Attachment: filename.ext heading

Attachments that cannot be converted (unknown format, conversion error) should be listed with a note rather than silently skipped.

Example output

# Email Message

**From:** sender@example.com
**Subject:** Q1 Report

## Content

Please find the Q1 report attached.

## Attachment: Q1_Report.xlsx

| Quarter | Revenue | Costs |
|---------|---------|-------|
| Q1 2026 | 1.2M    | 0.8M  |

Additional context

The recursive converter call pattern (passing attachments back through MarkItDown) is already used in ZipConverter for processing zip contents. The same approach would work here with minimal new code.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with EmlConverter._get_body() and the recursive converter call pattern in ZipConverter, then trace the MarkItDown converter entry point used for file bytes and filenames. Done means attachment MIME parts are converted beneath named headings, while unsupported or failed attachments produce an explanatory note instead of being skipped.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.