Home » Blog » MBOX File » How to Extract Attachments From MBOX File on Windows and Mac

How to Extract Attachments From MBOX File on Windows and Mac

Neeraj Kumar
Published By Neeraj Kumar
Debasish Pramanik
Approved By Debasish Pramanik
Published On
Last Updated

MBOX files store attachments as encoded text, so you must import the file or use a script to extract attachments from MBOX file data. You can use Thunderbird, Apple Mail, a Python script, or extractor software. Thunderbird and Apple Mail need an import first and save attachments from selected emails. Python reads one file with no filters, and the software trial saves 10 attachments. Test one copied file and compare the saved count with your emails.

MBOX files store every attachment inside its email as encoded text so you cannot open the file and copy a PDF or photo out of it.

People extract attachments from MBOX file archives to save space, to give invoices to an auditor or to move photos to a new computer. Email clients show attachments one email at a time and that pace is too slow for thousands of emails.

Four ways to extract attachments from MBOX file archives appear below with the limits of every method, a checklist and a comparison table near the end.

Why do People Extract Attachments From MBOX File Archives?

Four reasons make attachment extraction from MBOX files useful.

  • Storage Space. Photos, PDF files and spreadsheets take more space than email text.
  • Audit and Legal Requests. Auditors ask for contract and invoice files and not for a full mailbox.
  • Direct Sharing. A saved file opens in any application and attaches to a new email without an email client.
  • Backup Safety. A second copy of every file remains available when the MBOX file gets damaged.

Where do Attachments Sit Inside an MBOX File?

MBOX files are plain text containers for one mailbox folder. Every attachment sits inside its email as a MIME part with a file name and an encoding.

RFC 2183 defines the attachment label and the file name a sender suggests. RFC 2045 defines base64 which turns binary files into plain text characters. Tools that extract attachments from MBOX file archives decode that text and save the original file.

Google Takeout exports Gmail as MBOX files and every attachment remains inside its email.

What to Check Before You Extract Attachments From MBOX File?

Prepare the file before you start.

  • Copy the MBOX file and use the copy.
  • Quit your email client first so no application uses the mailbox file.
  • Free disk space for the files because attachments need room outside the MBOX file.
  • Create an empty destination folder with a short path.
  • Count the emails with attachments in one folder so you can compare the result later.

Saving attachments does not remove them from the MBOX file. MBOX file size remains the same.

Which Free Methods Save Attachments From Your MBOX File?

Three free methods extract attachments from MBOX file archives. Both email clients import the file first and a Python script opens the file directly.

Thunderbird Attachment Pane (Free, Needs an Import)

Thunderbird opens mailbox folders and not MBOX files. Import the archive and then save the attachments.

  1. Open Tools > Add-ons and Themes, search ImportExportTools NG and install it with Add to Thunderbird. Thunderbird asks for a restart.
  2. Select Local Folders and open Tools > ImportExportTools NG > Import mbox file.
  3. Select the option for one or more MBOX files and browse to your file. Thunderbird shows the emails in a new folder below Local Folders.
  4. Select an email that shows a paperclip icon.
  5. Click Save All in the attachment bar and select a destination folder.
  6. Right click one attachment and select Save As when you need a single file.

AttachmentExtractor Continued saves the attachments of many emails together. Its listing says it extracts all attachments from selected messages.

Install the extension from Tools > Add-ons and Themes and restart Thunderbird. Select the emails and open the context menu. Choose the extension entry.

Mozilla has not reviewed the extension according to its listing. Thunderbird saves attachments from imported folders only.

Apple Mail on Mac (Free, Needs an Import)

Mail on Mac saves attachments from emails in a mailbox. Import the MBOX file before you start.

  1. Import the MBOX file with the MBOX Import Steps for Apple Mail we explain in another guide.
  2. Select an email with an attachment in the new mailbox.
  3. Click the Attach button in the message header and select Save All. Select File > Save Attachments as another way.
  4. Select a location and click Save.

Apple Mail saves files in the Downloads folder unless you select another folder under Mail > Settings > General. Apple explains the steps in View, save or delete email attachments in Mail on Mac and documents Save All for the attachments in one email.

Python Script (Free, One File at a Time)

Python can save attachments from MBOX file data with its mailbox module and needs no email client and no import.

  1. Install Python 3 on your computer when you have none.
  2. Save the script below as extract_attachments.py in a folder.
import mailbox, email.policy, os, re, sys

source, folder = sys.argv[1], sys.argv[2]
os.makedirs(folder, exist_ok=True)
box = mailbox.mbox(source, factory=lambda f: email.message_from_binary_file(f, policy=email.policy.default))
saved = 0
for number, message in enumerate(box, start=1):
    for part in message.walk():
        name = part.get_filename()
        data = part.get_payload(decode=True)
        if not name or data is None:
            continue
        name = re.sub(r'[\\/:*?"<>|]', '_', name)
        with open(os.path.join(folder, f'{number:05d}_{name}'), 'wb') as f:
            f.write(data)
        saved += 1
print(saved, 'attachments saved')
  1. Windows users open PowerShell and Mac and Linux users open Terminal. Move to the script folder with the cd command.
  2. Use the command below on Windows.
python extract_attachments.py Inbox.mbox attachments
  1. Use the next command on Mac and Linux.
python3 extract_attachments.py Inbox.mbox attachments
  1. Type your own MBOX file name in place of Inbox.mbox. Open the attachments folder to see the files.

Python adds the email number before every file name so two files named invoice.pdf never overwrite one another. Python also replaces characters like / and ? with an underscore because Windows rejects them.

Senders suggest the file name and RFC 2183 tells receiving software to check that name before it saves a file.

Python saves parts that have a file name. Inline images without a name are not saved and the script has no date, size or type filter.

How to Extract Attachments From MBOX Files Using EmailDoctor Software?

EmailDoctor MBOX Attachment Extractor saves attachments from MBOX, MBS and MBX files and from MBOX files with no extension. Software works with no email client and extracts attachments without removing them from the emails.

Install the software on Windows 11, 10, 8 or 7. Server 2008, 2012 R2, 2016 and 2019 also work. Mac users get the same features and steps in the Mac edition and need Java 8 installed.

Seven features shape the result.

  • Many Files Together. Add one file or a folder of MBOX files and process them in one session.
  • Folder Structure. Copy your folder structure or save files in one place and create a separate folder for every file type if you want.
  • Date Filter. Enter two dates to save attachments from emails in that range only.
  • Size and Type Filters. Save attachments up to a size or above it with a maximum of 100 MB and include or exclude extensions like pdf and jpg.
  • Naming Convention. Name attachments and attachment folders by Subject, Date or From so files sort themselves.
  • Duplicate Names. The software renames duplicates in the same folder and never overwrites a file.
  • Report. A CSV report shows the files processed and the failures.

Extract Attachments on Windows Step by Step

  1. Open the software as an administrator with the Run as Administrator option. Extractor home screen
  2. Use Add File(s) to select single files or Add Folder to add a folder. Select the MBOX or MBS files you need and click Open. Files without an extension work too and the MBX tab opens MBX files. Add File and Add Folder buttons Open window with MBOX files
  3. Check the files in the list. Click Remove or Remove All to delete a wrong file from the list. Click Search Files to locate MBOX files on your computer. MBOX files added to the extractor
  4. Select Maintain Folder Hierarchy to copy your folder structure or No Folder Hierarchy to save files in one place. Two more options create one outer folder or a folder for every file type. Click Next. Folder hierarchy options
  5. Wait while the software shows the folders of your MBOX files. Folder list while the extractor scans the files
  6. Select a destination folder for the attachments and click Next. Destination folder selection
  7. Open the Filter tab. Click Add under the date filter and set the start and end dates in the Date Range window. Filter tab with date filter Date Range window
  8. Select File Size to save attachments Upto or More Than a size in MB. Select File Type to Include or Exclude extensions and type them in lowercase. File Size and File Type filters
  9. Select a naming convention for attachments and for the attachment folders. Naming convention list
  10. Click Extract and wait for the success message. Click OK. Extract button Extraction success message
  11. Check the Report tab for the number of files done and pending and the destination path. Progress summary
  12. Go to the destination folder and view the extracted folders and the attachments in them. Extractor software also creates an export report in CSV format. Extracted attachment folders Extracted attachment files

    Search for the email before you extract attachments from MBOX file archives. Our Search MBOX File Data guide shows how to find one email in a large file.

    Trial edition extracts the first 10 attachments only.

Which Method to Extract Attachments From MBOX File Fits Your Archive?

Four methods extract MBOX attachments but they differ in speed and control.

FeatureThunderbirdApple MailPython ScriptExtractor Software
Import stepYesYesNoNo
Operating systemWindows, Linux and MacMacWindows, Linux and MacWindows and Mac
ScopeOne email or selected emails with the extensionOne emailOne MBOX fileMany files or folders
FiltersNoneNoneNoneDate, size and file type
CostFreeFreeFreeFree trial, paid full edition

Thunderbird and Apple Mail suit a few emails and the script suits one file when you know Python. Extractor software suits large archives and repeated extractions.

What Problems Appear While You Extract Attachments From MBOX File?

Six problems slow attachment extraction.

  • Save All Button Missing. Select an email that shows a paperclip icon because emails without attachments show no button.
  • Extension Entry Missing. Restart Thunderbird after you install the extension because the menu entry appears after a restart.
  • Python Command Not Found. Type python3 on Mac and Linux and install Python 3 when both commands fail.
  • Script Finds No File. Move to the folder with the MBOX file or type its full path.
  • Only 10 Attachments Saved. The trial edition stops at 10 attachments so buy the full edition for more.
  • Fewer Files Than Expected. Remove the date, size and type filters and open the Report tab to see the counts.

Frequently Asked Questions

Can I Extract Attachments From MBOX File Data Without an Email Client?

Yes. Python and extractor software open the MBOX file directly. Thunderbird and Apple Mail need an import first.

Can I Process Many MBOX Files at Once?

Yes. Click Add Folder in the extractor software to process many files in one session. Python handles one file at a time.

Can I Save Only PDF Attachments?

Yes. Select File Type in the extractor software, choose Include and type pdf in lowercase.

Does Extraction Remove Attachments From the MBOX File?

No. Extractor software and the Python script save copies and do not modify the MBOX file.

What Happens to Duplicate Attachment Names?

Extractor software renames duplicates in the same folder instead of overwriting them. Python adds the email number to every file name.

Can I Save Attachments From a Gmail Export?

Yes. Google Takeout exports Gmail in MBOX format and every method in this guide opens that file.

Does the Extractor Software Work on Mac?

Yes. Mac users get the same features with Java 8 installed.

Does the Software Open MBOX Files With No Extension?

Yes. Extractor software opens MBOX files with no extension and MBS and MBX files too.

Does the Software Create a Report?

Yes. Extractor software saves a CSV report with the files done and the failures.

Is There a Free Trial?

Yes. Trial edition extracts the first 10 attachments from your files.

Final Words

People extract attachments from an MBOX file because every attachment sits inside its email as encoded text. Both email clients save attachments from emails you import and a Python script saves them from one file without an email client.

Make a backup copy and test one small file first. Compare the saved file count with the number of emails that have attachments.

EmailDoctor software processes many MBOX files with date and size filters and saves a report.

  • MBOX files store attachments inside emails as encoded text so every method decodes and saves them.
  • Thunderbird and Apple Mail save attachments from imported emails while a Python script saves them from one file.
  • Extractor software processes many files with file type filters on Windows and Mac.
  Neeraj Kumar

By Neeraj Kumar

Neeraj Kumar is a Principal Technical Architect at EmailDoctor with 19+ years of experience in email migration, cloud migration, data recovery and digital forensics. He guides enterprise teams through Exchange, Office 365 and Google Workspace projects and shares what works as an EmailDoctor writer. Every method in his posts is tested on Windows and Mac before it goes live.