Export and save email

How to Save an Email as a File

Updated 3 min read

On this page
  1. Choose a file for the job
  2. Save one email from Gmail, Outlook, or Apple Mail
  3. Save email as files with mailmd
  4. When you need more than one email

To keep an email on your computer, choose a file that fits how you will use it. A PDF is a convenient reading copy. An email file such as EML is meant to be opened as a message in compatible mail software. For a local copy of many messages, mailmd saves each email as a Markdown file, a text document that can include links and formatted content.

To keep a local collection of emails up to date, use mailmd: it copies messages into a folder on your computer and can also save each original EML file. For a single email, Gmail, Outlook, and Apple Mail also have built-in save or print options.

Choose a file for the job #

Use a PDF when you need a document that is easy to read or share. A PDF made by printing an email might not include every attachment. It might also omit technical message details or linked items. Check the saved copy if those matter.

Choose EML to save the email as a message. Gmail’s download command saves a message as EML, and Apple Mail on Mac can save its raw message source as EML. Outlook offers message-saving options that vary by version; Microsoft documents the steps for new Outlook, classic Outlook, and Outlook on the web. The format you can open depends on the mail software available to you.

Save one email from Gmail, Outlook, or Apple Mail #

In Gmail on a computer, open the message, select More, then choose Download message. Gmail saves an EML file. To make a PDF instead, open the message and select More → Print, then choose Save as PDF in the print window. For a full conversation, use Gmail’s Print all option. See Google’s instructions for downloading a message and printing Gmail messages.

In Outlook, open or select the message and use Save as in new Outlook, File → Save As in classic Outlook, or More actions → Download in Outlook on the web. The available file formats depend on the Outlook version.

On a Mac, Apple Mail lets you select a message and choose File → Save As. Choose Raw Message Source for an EML file or File → Export as PDF for a PDF. Apple describes these options in its Mail storage and message-saving instructions.

After saving, open the file and confirm that it contains the right message. Check any attachments you need to keep.

Save email as files with mailmd #

mailmd is a free, open-source command-line tool. A command-line tool runs when you enter instructions in a terminal. It copies mail into a folder on your computer, creating one Markdown file per message. Attachments sit beside their messages, and --keep-raw also saves each original EML file.

To start, install mailmd and connect the mailbox:

curl -fsSL https://raw.githubusercontent.com/vincentsch/mailmd/main/install.sh | sh
mailmd connect imap --email you@example.com
mailmd sync

IMAP is a standard way for a mail program to access messages stored in a mailbox. Some providers require an app password. mailmd tells you when you need one. Gmail can connect through IMAP or through the Gmail API; Outlook.com and Microsoft 365 connect through Microsoft Graph. These API options require you to register your own OAuth app, which sets up sign-in, in Google Cloud or Microsoft Entra. The command you use to connect depends on the mailbox; setup details are in the mailmd project instructions.

mailmd stores the files in ~/mail/<account>. It opens mailbox folders in read-only mode and requests read access, so it does not mark messages as read, move or delete them, or send mail. mailmd stores login details outside the saved email files. Only your user account can read them, and they are not encrypted. The archive itself is never deleted by mailmd. Review the mailmd website before choosing where to store sensitive email.

When you need more than one email #

Saving messages one at a time works for a few files. mailmd is a better fit for a continuing local archive: each mailmd sync adds new mail and updates read and starred marks. To keep the copy current, schedule mailmd sync --quiet with your computer’s scheduling tools. You can search the resulting files with an editor or tools such as grep, and back up the folder like other local files.

For a one-time export of a larger mailbox, Gmail offers Google data exports, while Outlook supports exporting mail to a PST data file. A mailbox export is different from saving one message; check the resulting files and attachments before relying on them.

Free and open source

Try mailmd

mailmd is a free command-line tool that copies your email into Markdown files on your computer, one file per message. It works with any IMAP mailbox, and with Gmail and Outlook through their own APIs.

Install

$ curl -fsSL https://raw.githubusercontent.com/vincentsch/mailmd/main/install.sh | sh

Set it up with your coding agent

Set up mailmd so you can read my email. Use https://github.com/vincentsch/mailmd: read its AGENTS.md and follow the steps. Connect my mailbox and run the first sync. Then show me where the files are.

More on export and save email