1. Save Gmail Attachments to Google Drive
Step 1
Open the Google Spreadsheet titled Send to Google Drive.
Digital Inspiration www.labnol.org
Page 1
2. Save Gmail Attachments to Google Drive
Step 2
Enter the names of one or more Gmail Labels in cell D4. The script will monitor Gmail messages
under these label and any attachments included in these message will get saved to your Google
Drive.
If you wish to save attachments from all Gmail messages, irrespective of the label name, just put all
in cell D4.
You can multiple labels separated by a comma. For instance, if you wish to extract mails from labels
Inbox, Sent Items and the Starred items in Gmail, put inbox, starred, sent in the cell.
It supports nested labels too though the syntax is a bit different. If the label's name is SubLabel
under ParentLabel, you need to put it as ParentLabel-SubLabel (notice the hyphen)
Digital Inspiration www.labnol.org
Page 2
3. Save Gmail Attachments to Google Drive
Step 3
Enter the names of the Google Drive folder in cell D5. The script will automatically save Gmail
attachments under a subfolder of this folder.
The subfolder's name will be the domain name from where that message was received. The
attachments saved in the Google Drive are also marked with the GMail Message ID making it easier
for you know where that message came from.
Digital Inspiration www.labnol.org
Page 3
4. Save Gmail Attachments to Google Drive
Step 4
Enter the names of a Gmail Label in cell D6 that will be used to mark processed messages.
When the script has saved attachments from a particular message, it will mark those messages with
this particular label to exclude that message from the queue forever.
Digital Inspiration www.labnol.org
Page 4
5. Save Gmail Attachments to Google Drive
Step 5
Now we need to authorize the program. Go the Gmail Attachments menu in the Google Sheet and
choose Authorize.
Digital Inspiration www.labnol.org
Page 5
6. Save Gmail Attachments to Google Drive
Step 5b:
Click OK at the Authorization Required dialog.
Digital Inspiration www.labnol.org
Page 6
7. Save Gmail Attachments to Google Drive
Step 5c
Click Accept at the Permissions screen. The script needs permissions to read your Gmail inbox and
save attachments in your Google Drive. Everything is running inside your own Google Drive and NO
ONE ELSE has access to any of your Gmail or Google Drive, including the developer of this
program.
Digital Inspiration www.labnol.org
Page 7
8. Save Gmail Attachments to Google Drive
Step 6
Now that the program is authorized, we need to run. Go to the Gmail Attachments menu again and
choose Run Program.
Digital Inspiration www.labnol.org
Page 8
9. Save Gmail Attachments to Google Drive
Step 7
The program is now running and will save attachments from Gmail to Google Drive at regular
intervals (every 5 minutes). You can close the Google Sheet and open Google Drive to monitor
incoming files.
Digital Inspiration www.labnol.org
Page 9
10. Save Gmail Attachments to Google Drive
Support & Resources
The Save Attachments to Google Drive program was written by Amit Agarwal of Digital Inspiration. It
is available in both free and premium versions.
Free: The free version is however limited to a single Gmail label and does not save attachments in
sub-folders.
Premium: The premium version supports Nested Labels, you can monitor messages in multiple
Gmail Labels and it saves attachments in subfolder thus keeping your Google Drive better
organized.
•
•
•
•
Tutorial: Save Attachments to Google Drive
Email: amit@labnol.org
Twitter: @labnol
See more Google Apps Script Projects
Digital Inspiration www.labnol.org
Page 10