Free & open source No login · No subscription · Runs on your computer
View on GitHub →
Home / Tools / Email Export
Tool 01 of 07

Convert a whole mailbox into organized PDFs.

Converts Outlook PST files and Gmail MBOX exports into one PDF per email, with From, To, Date, and Subject at the top and attachments saved alongside. Two scripts, run one after the other.

What it does

Email Export converts an entire mailbox export — an Outlook PST file or a Gmail MBOX export — into a clean set of PDFs, one per email. Every PDF starts with a header showing From, To, Date, and Subject, so the printout reads like a proper record. Attachments are saved in a folder alongside each email and listed in that email's header, so nothing gets orphaned from its message.

It works in two stages, which is why there are two scripts. Step 1 pulls each individual email out of the mailbox file as a standard EML file. Step 2 converts those EML files into formatted PDFs. You run them one after the other.

Everything runs locally. Your emails never leave your computer. Nothing is uploaded and no account is needed.

Before you start: getting your mailbox file

Gmail

Use Google Takeout (takeout.google.com). Deselect everything except Mail, export, and download. You'll get an MBOX file — that's what the script reads directly.

Outlook (PST files)

The script reads MBOX, so a PST file needs one conversion first. On a Mac, the simplest option is PST Converter Pro ($19.99 on the Mac App Store) — open your PST, export as MBOX, done. Once you have an MBOX file, the rest of the process is identical.

Setup

  1. Install Python 3 (once)

    Download it free from python.org/downloads and run the installer. On Windows, check the box that says "Add Python to PATH" during installation.

  2. Install the one library this tool needs

    Open Terminal (Mac) or Command Prompt (Windows) and paste the command for your system:

    Mac
    /usr/local/bin/pip3 install reportlab
    Windows
    pip install reportlab
  3. Download both scripts

    Use the download buttons in the sidebar (or at the top of this page). Save both files into the same folder — for example, a folder on your Desktop called email-export.

Running the tool

  1. Tell the scripts where your files are

    Open step1_extract_emails.py in any text editor (TextEdit, Notepad — nothing fancy needed). At the very top is a section labeled JOBS. Edit it with the path to your MBOX file and the folder where you want the extracted emails to go. Do the same in step2_convert_to_pdf.py, pointing it at the extracted-emails folder and an output folder for the PDFs. Save both files.

  2. Run Step 1 — extract the emails

    In Terminal or Command Prompt, navigate to your folder (type cd, a space, then drag the folder into the window and press Enter). Then run:

    Mac
    python3 step1_extract_emails.py
    Windows
    python step1_extract_emails.py

    You'll see it count through the mailbox as it saves each email as an EML file.

  3. Run Step 2 — convert to PDF

    Mac
    python3 step2_convert_to_pdf.py
    Windows
    python step2_convert_to_pdf.py

    Each email becomes its own PDF with the From / To / Date / Subject header at the top. Attachments are saved alongside and listed in the header.

  4. Open the output folder

    That's it. Your emails are now organized PDFs, ready for review, production, or filing.

Common errors

ErrorFix
command not found: python3Python isn't installed (or isn't on your PATH). Install it from python.org — on Windows, re-run the installer and check "Add Python to PATH."
No module named 'reportlab'The library didn't install. Re-run the install command from Setup step 2. On a Mac, use the full /usr/local/bin/pip3 path shown above.
FileNotFoundErrorA path in the JOBS section is wrong. Check for typos — the easiest fix is dragging the actual file or folder into Terminal to paste its exact path.
PermissionErrorThe output folder is somewhere the script can't write (or the file is open in another program). Point the output at a folder in your home directory, like Desktop or Documents.
Script runs but 0 emails foundThe file you pointed at isn't a valid MBOX. If you started from a PST, make sure the conversion to MBOX completed. Gmail Takeout files sometimes download as .mbox inside a ZIP — unzip first.

More tools in the kit