How to Save Emails to a Folder on Your Computer
On this page
To save email on your computer, choose a format that suits how you plan to use it. An .eml file preserves an individual message for an email program; a PDF is convenient for reading and sharing; a mailbox export stores many messages together. Saving a message to a folder in Gmail or Outlook alone does not create a file on your computer.
For a readable local archive with one file per message, mailmd is a practical choice. It copies email into Markdown files in a folder on your computer. If you need one message as an email file or PDF, use the save or print command in your mail service instead.
Choose a format for the email #
Markdown files are readable text files that can include formatted message content, links, and tables. mailmd saves each message and its headers in a separate Markdown file. It stores attachments beside the file. Use this format when you want a folder of messages that you can open in an editor or search with ordinary computer tools.
Choose .eml when you want to keep an individual message in a format supported by email programs. Choose PDF when you need a document that is easy to read without an email program. A PDF of a message does not necessarily include its attachments, so save and check those separately.
Save messages with mailmd #
mailmd is a free, open-source command-line tool. A command-line tool runs when you enter text commands in a terminal, a program for typing commands to your computer. mailmd works with mailboxes that use IMAP, a standard for accessing email stored on a mail server. These include iCloud, Fastmail, Yahoo, and private mail servers. mailmd connects to Gmail through the Gmail API and to Outlook.com and Microsoft 365 through Microsoft Graph. These APIs let software access email services. To use either connection, you need to set up your own OAuth app, a registered app that lets mailmd connect to your account, in Google Cloud or Microsoft Entra.
To install mailmd and manually copy messages to your computer, run:
curl -fsSL https://raw.githubusercontent.com/vincentsch/mailmd/main/install.sh | sh
mailmd connect imap --email you@example.com
mailmd syncUse the IMAP command for an IMAP mailbox. Some providers require an app password, a separate password for mail programs; mailmd tells you when. For Gmail through its API, use mailmd connect gmail --client-secret client_secret.json. For Outlook.com or Microsoft 365, use mailmd connect outlook --client-id <id>. Follow mailmd’s connection instructions to set up the required OAuth app. Mail is saved under ~/mail/<account>. The tool runs on Linux, macOS, and Windows in Git Bash.
mailmd opens mailboxes in read-only mode, which means it can view messages but cannot change them. It does not mark messages as read, move or delete them, or send mail. Each time mailmd syncs, it adds new messages to the folder and updates which messages are marked as read or starred. It never deletes archived files, even if a message is later deleted from the mail server. Spam and trash are excluded unless requested. For Gmail over IMAP, it syncs All Mail, which includes archived messages.
You can set your computer's built-in scheduler, which runs commands at set times, to run mailmd sync --quiet and keep the folder current. mailmd has no built-in search engine, but you can search the files in an editor or use tools such as grep. Logins are stored outside the archive in files readable only by your user; they are not encrypted. mailmd sends no telemetry and runs no mailmd server. See the mailmd code and instructions.
Save one message from Gmail, Outlook, or Apple Mail #
In Gmail on a computer, open the message, select More, then Download message. Gmail saves an .eml file with its attachments that compatible email programs can open, as described in Gmail Help.
Outlook’s commands depend on the version. In new Outlook for Windows, select the message and choose More actions > Save as. In classic Outlook, open the message and choose File > Save As. In Outlook.com or Outlook on the web, choose More actions > Download; move the downloaded file from Downloads to your chosen folder if needed. Microsoft documents these Outlook save options.
In Apple Mail on Mac, select the message and choose File > Save As to pick a format and destination. You can also choose File > Export as PDF for a readable copy. Apple describes these Mail saving options.
For a PDF from Gmail, use More > Print for one message or Print all for the full conversation, then choose the computer’s save-as-PDF option. A conversation is an email and its replies. Check whether attachments were saved separately; printing the message does not guarantee that they are included.
Save a full mailbox #
If you prefer an export from your email provider, Google Takeout can export Gmail data, classic Outlook can export messages to a PST file, and Apple Mail can export selected mailboxes as MBOX files. PST and MBOX are formats for storing groups of email messages. These formats gather messages differently from mailmd’s folder of Markdown files. Follow the provider’s Gmail export instructions, Outlook PST instructions, or Apple Mailbox export steps.
Check the saved files #
Open the destination folder and confirm that the files appear there. Open a few messages and check the sender, date, subject, and body. If attachments or every reply in a conversation matter, verify those separately. If you need offline access, confirm the files open without an internet connection; files stored as online-only placeholders in a synced folder are not available offline.
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.