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.
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
-
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.
-
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 reportlabWindowspip install reportlab -
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
-
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.
-
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:
Macpython3 step1_extract_emails.pyWindowspython step1_extract_emails.pyYou'll see it count through the mailbox as it saves each email as an EML file.
-
Run Step 2 — convert to PDF
Macpython3 step2_convert_to_pdf.pyWindowspython step2_convert_to_pdf.pyEach email becomes its own PDF with the From / To / Date / Subject header at the top. Attachments are saved alongside and listed in the header.
-
Open the output folder
That's it. Your emails are now organized PDFs, ready for review, production, or filing.
Common errors
| Error | Fix |
|---|---|
| command not found: python3 | Python 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. |
| FileNotFoundError | A 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. |
| PermissionError | The 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 found | The 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. |