Convert EML to CSV

Thinking of turning EML email files into a CSV spreadsheet? Learn what the conversion keeps and what it drops, how encoding and quoting can break the result, and when to keep the original messages.

Converting EML files to CSV turns individual email messages into rows of a table. That is useful when you need to sort, filter, count or review many messages at once. It is a poor substitute for the messages themselves. This review covers what the conversion changes, where meaning gets lost, and how to tell whether the output will hold up in the spreadsheet or tool you plan to use.

Is converting EML to CSV the right choice?

Converting is a good fit when the goal is analysis or inventory. Examples include listing who sent what and when, finding messages by subject, building a review log, or loading message metadata into a database. The main benefit is that hundreds of separate files become one structured table that any spreadsheet or data tool can open.

The cost is fidelity. A CSV row cannot hold an email's full structure. Formatting, inline images, attachments and the original header block do not survive as usable content. Long message bodies become hard to read once they are packed into a single cell.

Keep the original EML files, or export them to plain text, in these situations:

  • You need to read or quote messages as they were sent, including formatting.
  • You may need the messages as records or evidence, where the original headers and exact bytes can matter.
  • Attachments are part of what you need, since a CSV can at most list their names.
  • You are dealing with only a handful of messages, where a table adds little over opening each file.

A sensible approach is to treat the CSV as an index that points back to the retained originals, not as a replacement for them.

What "convert EML to CSV" can mean

People use the phrase for at least three different jobs. Which one you need decides what a good result looks like.

  • Message index: one row per email, with columns such as date, sender, recipients, subject and message ID.
  • Full content export: the same as an index, plus the message body text in a column.
  • Address extraction: a list of contacts pulled from the From, To and Cc fields, often with duplicates removed.

A converter built for one of these jobs may handle the others badly. Check which output a tool actually produces before relying on it.

What the conversion actually changes

An EML file is a single email stored in the standard Internet message format. It has a block of headers (From, To, Cc, Subject, Date, Message-ID and many others), followed by a body. Most modern messages use MIME, which lets one message contain several parts: a plain-text version, an HTML version, and attachments. Those parts are often encoded with base64 or quoted-printable so they survive transport.

CSV is a much simpler format. It is plain text, with one record per line and fields separated by commas. A field that contains a comma, a double quote or a line break must be wrapped in double quotes, and any quote inside it is written twice. TSV works the same way but separates fields with tabs.

Moving from one format to the other therefore involves several real changes to the stored data. This is not a visual or presentation-only transformation. The converter has to do the following:

  • Parse the headers and decode encoded words. Non-ASCII subjects and names are often stored in an encoded form that has to be turned back into readable text.
  • Choose a body part. With both plain-text and HTML versions present, the converter must pick one. Picking HTML puts markup into the cell. Picking only plain text can leave the body empty for HTML-only messages.
  • Decode the transfer encoding and character set of the chosen body part.
  • Flatten multi-value fields. Several recipients end up as one text string in a single cell.
  • Drop or summarize attachments, usually by listing their filenames.
  • Quote and escape every field so that commas and line breaks inside the email text do not split or shift columns.

Each step is a point where a converter can lose or distort meaning. When you evaluate a tool or script, those are the places to check.

How email elements map to CSV

Email element | Typical CSV result | Main risk
From, To, Cc | Text columns; several addresses joined in one cell | Display names containing commas or quotes must be escaped correctly
Subject | Text column | Undecoded encoded words appear as gibberish
Date | Text column in the email's date format | Spreadsheets may not recognize it as a date, and time zones can be misread
Message-ID | Text column | Usually safe; useful for linking rows back to originals
Plain-text body | Long text cell with embedded line breaks | Poor quoting splits the message across rows
HTML body | Text cell containing markup, or stripped text | Markup clutters the text; stripping can lose structure such as lists and tables
Attachments | Filenames only, or omitted | The content itself is not carried over
Reply chains and quoted text | Kept inside the body cell | Thread structure is not represented as separate rows

A minimal local approach

If you are comfortable running a script, Python's standard library can parse EML files and write CSV without uploading anything. The sketch below builds a message index with plain-text bodies and a list of attachment filenames. It is illustrative and has not been run against your files. Malformed messages or unusual character sets may need extra error handling.

import csv
import glob
from email import policy
from email.parser import BytesParser

fields = ["file", "date", "from", "to", "cc", "subject",
          "message_id", "body_text", "attachments"]

with open("messages.csv", "w", newline="", encoding="utf-8") as out:
    writer = csv.DictWriter(out, fieldnames=fields)
    writer.writeheader()
    for path in sorted(glob.glob("mail/*.eml")):
        with open(path, "rb") as f:
            msg = BytesParser(policy=policy.default).parse(f)
        body = msg.get_body(preferencelist=("plain",))
        writer.writerow({
            "file": path,
            "date": msg.get("Date", ""),
            "from": msg.get("From", ""),
            "to": msg.get("To", ""),
            "cc": msg.get("Cc", ""),
            "subject": msg.get("Subject", ""),
            "message_id": msg.get("Message-ID", ""),
            "body_text": body.get_content() if body else "",
            "attachments": "; ".join(
                part.get_filename() or "" for part in msg.iter_attachments()
            ),
        })

In this sketch, the csv module handles quoting of commas, quotes and line breaks. The default email policy decodes encoded header words. Messages that contain only an HTML body will get an empty body cell. Adding "html" to the preference list would fill those cells, but with markup included.

Will the CSV stay readable and usable after sharing?

A CSV file is plain text, so copying and pasting it does not depend on fonts or special characters the way styled text does. Most usability problems come from how the receiving program interprets the file.

  • Character encoding: Names and subjects in non-Latin scripts, accented letters and emoji need the file to be read as UTF-8. Some spreadsheet programs guess the encoding when opening a CSV and can display garbled text if they guess wrong. Importing with an explicit encoding setting avoids the guess. Whether a given program needs a byte order mark at the start of the file is version-specific, so test with your own software.
  • Embedded line breaks: Correctly quoted bodies keep their line breaks inside one cell. Tools that read CSV line by line, rather than with a proper CSV parser, will break those rows apart.
  • Delimiters and regional settings: In some locales, spreadsheet software expects semicolons, not commas. TSV can be a safer choice when the data contains many commas.
  • Dates: Email date strings are not always recognized as dates. Converting them to a consistent format such as ISO 8601 makes sorting reliable.
  • Formula injection: Spreadsheet programs may treat a cell beginning with =, +, - or @ as a formula. Email content comes from outside senders, so neutralize such values (for example, by prefixing them) before anyone opens the file in a spreadsheet.
  • Cell size limits: Very long bodies can exceed what some spreadsheet programs allow in one cell, which can truncate text. Check the limits of your destination program.

Reading order and accessibility deserve their own check. A spreadsheet presents each message as a row of cells, and a screen reader user moves through it cell by cell. Short metadata columns work reasonably well that way. Long message bodies, HTML markup and quoted reply chains packed into one cell are much harder to follow.

No documentation or test results for particular screen readers or spreadsheet programs were available for this review, so no claim is made about how a specific combination behaves. If the CSV will be read with assistive technology, give those readers the original messages or a plain-text export for the actual reading, and keep the CSV for searching and sorting.

Search and editing both benefit from the conversion when the text is decoded properly, because subjects and bodies become searchable in one place. Editing the CSV, however, does not change the original emails. Once edited, the table should no longer be treated as an accurate record of what was sent.

Privacy when choosing a converter

Email files often contain personal information, addresses and sometimes confidential content. Whether an online converter stores, logs or deletes uploaded files cannot be judged from how its site looks or what its marketing says. Only a stated policy you have read, or your organization's own assessment, can answer that. When there is any doubt, a local method such as a script or desktop software you control avoids sending the messages anywhere.

Checking a converted file

  • The row count matches the number of EML files, plus one header row.
  • No row has more or fewer columns than the header.
  • Subjects and names that contain non-ASCII characters display correctly.
  • Multi-line bodies stay within one row.
  • HTML-only messages have the body content you expect: empty, stripped text or markup.
  • Attachment names are listed if you need them.
  • A few rows, checked against their original messages, match on sender, date and subject.

Gaps in this review

No specific converter products, prices, performance figures or test results were available as evidence. This article therefore does not rank or recommend particular tools. The guidance above rests on how the EML and CSV formats are defined and on general spreadsheet behavior. Confirm details such as encoding handling, cell limits and assistive technology behavior in the exact software you plan to use.