Google Apps Script to import .eml into my Gmail Inbox

Saqib Ali picture Saqib Ali · Aug 24, 2012 · Viewed 15.2k times · Source

I have several hundred .eml files in GDrive that I would like to import into my Gmail as emails. Can anyone suggest a Google Apps Script that will let me do this? I am fairly proficient in Google Apps Script, I just need some hints as to how to proceed.

Answer

lingochad picture lingochad · Oct 23, 2013

I know this thread is a bit old, but I came across a way to import single (or multiple) eml files into Gmail today and thought I'd share. My use case is that my company migrated to Google Apps and imported my email into a gmail account. I had previously been using Pop3 to pull those emails into another gmail account to make use of the gmail interface. Unfortunately my sent mails did not get put back into my corporate email sent folder and therefore did not get imported into the new gmail account. Here is how I got my sent email into the new Google Apps gmail account.

Download a copy of Gmail Backup from here. I used it to backup the entire contents of a gmail account. Enter your gmail credentials and give it a folder to download into and it goes off to work. It sorts the emails into single eml files and uses month and year folders. The folder structure is MyGmailBackup (folder) 2012 10 - October 2012 eml files are in here. 11 - November 2012 eml files are in here. 12 2013 01 02

It has a restore option that is very helpful for importing into Gmail. Using the same Gmail Backup program I changed the credentials to the gmail account I wanted to restore emails into. If I had wanted to import all the emails I could have set the folder to MyGmailBackup. I only wanted to import some of the emails so I created a folder for holding the emails I wanted to import into the second gmail account. I then dropped a single eml file into the folder and hit Restore. Upon refreshing my gmail in my browser my email was there. It even threaded properly. I then selected multiple eml files I wanted to restore and tried it again. It worked perfectly. Now I have my sent email in their threads and am back in business where I left off. Hope this helps someone out.