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.