Gmail integration with Google Drive to archive emails is something a lot of people want. But Google doesn't provide any such integration by default. Here's an easy way to archive all your emails in any label to your Google drive using Google scripts.All emails will be archived as PDF files in a folder called "Gmail backup" in your drive.

Archving your emails.
Follow these steps to archive your mails -
- First open this "Gmail archiver spreadsheet" and select File->Make a Copy. This will copy the spreadsheet to your Google Drive.
- Just wait for the sheet to fully load and the "Gmail Drive Backup" menu to appear. It may take a few seconds depending on your internet speed, so please be patient.
- Select "Gmail Drive Backup" menu, click "Initialize" and grant the permissions required.

- Now select "Gmail Drive Backup" again and click "Start Daily Gmail Backup". You will be asked to enter the Gmail Label you want to archive.

That's it, the script will now convert your emails from that label into pdf files and move them to a new "Gmail backup" folder on your Google drive. Attachments also will be moved. The PDF email will also have a link to the attachment stored in your drive which you can download any time you want. You will also get a confirmation message once done.

Here are some features of this script -
- Option to test out one time or doing regular daily archivals.
- All mails are stored as PDF files with the original html/css styling intact. That means the PDF version in your Google drive will look exactly the same as the original mail.
- Every time an archival is done, the details get updated in the spreadsheet. You can open it any time to see what was done.
- Attachments are also archived to Google drive and links to attachments inserted in original mail for easy download.
- Regular backups can be stopped any time using the "Stop gmail backups" menu.
The only limitation is that images which are embedded as external links won't appear in the PDF version. All other images and attachments will remain in tact. But usually this only applies to mails like email newsletters. Also note that the archival is one directional. That means mails archived to Google drive can not be brought back to Gmail in the form of the original Mail. So use this only for emails you want to store on your drive and don't want on Gmail.
Here's a working video of the script in action.
Also See: Auto Delete old Emails in Any Gmail Label.
You may also like
Caterina Rindi
Mar 08, 2013
Lovely little script. Thanks for sharing it!
Arun
Mar 12, 2013
Most welcome and glad it was of help Caterina :-)
Prasong Pansri
Mar 13, 2013
i not sure what is i am doing wrong it's generate email to pdf files
but no any attached files create on my google drive, please advise.
thank a lot your for sharing,
Fabien Cordiez
Mar 26, 2013
Google docs do not take up any space in Google Drive! I am keen to find an add-on or a Script which allows for gmail messages and attachments to be saved into Google Drive in 'Google doc' format. Any ideas whether such a script exists?
Arun
Mar 26, 2013
Hi Fabien, as far as I know, such a facility does not exist. You could write a script which reads content from the email and creates a text document out of it. But that would be error prone as 99% emails will be in html and you can't get the formatting right.
Google had even added such an experimental feature in Google labs earlier, but seems to have withdrawn it later on.
That's the reason to use pdf format in the first place.
KC
Apr 17, 2013
Great Script, is there any way of doing this and NOT removing the email from Gmail.
Arun
Apr 17, 2013
Hi KC, that is difficult to do as keeping checkpoints for backedup emails is something not really possible to do with Google script.

