I was surprised that I could practically not find anything on the topic, as suggested here asking anew on SuperUser rather than Stack Overflow.


I have been emailing to several companies, and want to transfer the history of one of these to a colleague. (We are on the same domain, and in case it is relevant can use the same google Drive). If really needed I could probably arrange a moment where we would both authenticate at the same time.

I am able to find the emails, for example with a Gmail search like to:corp1.com OR from:corp1.com

There are thousands of mails to and from corp1, if needed I would be willing to not bring the attachments over.


How could I get these mails in the hands of a colleague?

Ideally in a way that they can fairly easily search through them (perhaps within Gmail, or just as local textfiles)

What have I tried/researched

  • I selected all of them and clicked 'forward', this starts to open a message per email...do not think this is scalable
  • I found that I could archive ALL email, however I do not want to give my colleague insight into anything unrelated to corp1
  • The closest I have come is selecting mails and 'forward as attachment', however it seems this only does a few dozen mails
  • Make sure to check out both answers, the oldest (accepted) one can do attachments, but the second one may be more security compliant. Commented Mar 18, 2022 at 20:35

2 Answers 2


There are several ways to achieve what you want.

  • Export a .pst, split it per message, delete all files that do not contain a certain label.

  • Go to your Inbox, and label all current items with a new label, then archive them (this will remove them from the Inbox). Create a another label and mark your search results with that label, and move these results back into your Inbox. Then use any known method to read your GMail into (for example) Outlook (you will have to enable IMAP in your GMail settings)

  • Export a .pst. Create a new email account. Import the PST and delete all emails except those you want the other person to have. Then give them the credentials.

  • 1
    I reckon PST is the way to go, keeps the messages fully intact (including headers - only 'forward as attachment' would do this in webmail clients). Just to clarify (it's a bit hidden in the answer), you will need an IMAP mail client to export and import.
    – MiG
    Commented Mar 16, 2022 at 11:42
  • I don't have Outlook (and we both use gmail), so I guess PST won't be available. I then discovered mbox which can be made via takeout.google.com and apparently allows you to download per label...except not for me: Your data for some services is unavailable for export because your Workspace Admin has disabled them. At this point I realize that any further attempts would essentially be hacking attempts against our own admins, so I will just stop and tell my manager to ping IT if we want this and let them figure out what I am allowed to do.
    – Dennis Jaheruddin
    Commented Mar 16, 2022 at 20:23
  • Also for other readers: Be aware that in method 2 you need to be careful as after you archive everything, a new message might come in... Also regarding point 3: Think carefully if it is a corporate setting, in general they will not like you upgrading mails to an ungoverned account.
    – Dennis Jaheruddin
    Commented Mar 16, 2022 at 20:24

If I read you right, you want to:

  • Go through a bunch of emails
  • Isolate a portion of them using a query to:corp1.com OR from:corp1.com
  • Share them with a/any user(s) having some other Gmail account (be it a colleague under the same or even another domain)
  • "Ideally in a way that they can fairly easily search through them"

If so, I believe your "easiest" approach would be using a script. It can be done in several ways.

"No need to reinvent the wheel".
I will here provide an (updated) approach as given here by Tiago Gouvêa.
His well written script will bring all your found emails within a Google Sheet.
The emails will be easily viewed by just sharing the sheet, without attachments and effortlessly searched

About the script

It's on gmail-to-google-sheets-script repository. Just read the content and follow the instructions.

How to use it

  • Click and leave open the gmail-to-google-sheets-script
  • Next, create a new Google Sheet
  • Access the menu Extensions > Apps Script. Click on it and you will be taken to a new tab having Code.gs
  • Delete everything (the sample code) in Code.gs
  • Go and Click to the right hand corner Raw version of gmailt-to-sheets.gs,
  • Copy the content and paste it in your Code.gs
  • Replace the value of SEARCH_QUERY to your real query (To avoid mistakes, do your search on gmail first, copy and paste the search terms there)
  • Select saveEmails on menu (near "run" and "debug" buttons)
  • Click on "Run" button
  • It will ask for authorization at first run, proceed accepting it (it's your Gmail account authorizing your Google Script account)
  • After run, the results will be applied to you sheet

Changing fields

If you want to save different message attributes, take a look at gmail-message class and change in your script file, the code below the comments with a ✏️ (pen).

PS: If you are not given rights to run a script, ask your IT to do it for you.

  • Great, worked like a charm and love that data never leaves the secure environment! Have also suggested a way to include the body of emails. Only drawback is that I don't see this working for attachments conveniently so I will keep the other answers as accepted so people may attempt that first if security permits. Commented Mar 18, 2022 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.