Export Emails as an MBOX archive?

33 views
Skip to first unread message

Dierk Polzin

unread,
Apr 15, 2026, 3:17:34 PM (7 days ago) Apr 15
to GAM for Google Workspace
All,
We had a member of our community pass away unexpectedly.

We would like to export all the files with a set of specific Labels to an portable file we can give the next of kin.  

gam user <targuser> print messages matchlabel <label> todrive tdtitle "<targuser>--<label>"

This generates a google sheet with all the header information and subject but no body.

Is there a way to export to an MBOX format?

Do I need:
Got Your Back (GYB) is a command line tool for backing up your Gmail messages to your computer using Gmail's API over HTTPS.

Thanks Dierk

Jay Lee

unread,
Apr 15, 2026, 3:44:29 PM (7 days ago) Apr 15
to google-ap...@googlegroups.com
No. GAM really isn't the right tool for this purpose. It's not a data migration tool.

Take a look at Google Vault or Takeout, they should be able to get what you want.

Jay Lee


--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-manager/16bb8de3-c525-45f5-8214-2b2edea15d81n%40googlegroups.com.

Ross Scroggs

unread,
Apr 15, 2026, 4:05:03 PM (7 days ago) Apr 15
to google-ap...@googlegroups.com
Add this option to the command: showbody

Ross
----
Ross Scroggs



Ross Scroggs

unread,
Apr 15, 2026, 4:53:03 PM (7 days ago) Apr 15
to google-ap...@googlegroups.com
Dierk,

This will give you something easier to read.

gam redirect stdout ./NokMessages.txt user <targuser> show messages matchlabel <label> showbody

Then you can upload NokMessages.txt

Ross
----
Ross Scroggs


On Apr 15, 2026, at 12:17 PM, 'Dierk Polzin' via GAM for Google Workspace <google-ap...@googlegroups.com> wrote:

Dierk Polzin

unread,
Apr 15, 2026, 7:18:28 PM (7 days ago) Apr 15
to GAM for Google Workspace
This works.... pretty darn slick...
Ross helped me figure it out...

gam user <username> export messages maxtoexport 0 matchlabel "<label>" targetfolder <username>-<label>

That dumps all the messages into a target folder with the username-label in your downloads folder...
Msg-13390b32332c8cf3.eml
Msg-1350bbfaf001e08d.eml
Msg-135494c3f25c29f6.eml
etc...etc

THEN use bash to merge the .eml into a plain text MBOX formatted file.
bash

for e in *.eml
do
date +"From - %a %b %d %H:%M:%S %Y" >> username_Shopping.mbox
cat "$e" >> username_Shopping.mbox
echo >> username_Shopping.mbox
done

THEN you have a large MBOX file that you can compress with zip..
and send to the user...

Gmail does not import MBOX but you can use Thunderbird or MacMail to import the MBOX files and then use imap to synch them over to google.

How to Import MBOX Files to Mac Mail
  • Open the Mail app on your Mac.
  • Choose File > Import Mailboxes.
  • Select "Files in mbox format" and click Continue.
  • Navigate to the folder containing your .mbox files, select it, and click Choose.
  • Click Done. The messages will appear in a folder named "Import" in your sidebar.
  • You can then drag the messages or folders from the "Import" folder to your existing mailboxes. 
Using Mozilla Thunderbird (Free & Most Common)
This is the recommended manual method to import MBOX files to Gmail. 
  • Install Thunderbird: Download and install Mozilla Thunderbird.
  • Add Gmail Account: Set up your Gmail account using IMAP.
  • Install ImportExportTools NG: In Thunderbird, go to Add-ons, search for ImportExportTools NG, and install it.
  • Import MBOX:
  • Right-click on "Local Folders" in the left panel.
  • Select ImportExportTools NG > Import mbox file.
  • Select "Import directly one or more mbox files" and choose your file.
  • Transfer Emails: Once imported, drag and drop the emails from the Local Folder to your Gmail inbox/folders within Thunderbird.



Reply all
Reply to author
Forward
0 new messages