Imagine this. You are reading a Gmail message on your mobile, the message contains one or more file attachments, you apply a label (say GoogleDrive) to that message and automatically all those attachments are saved to one of the folders on your Google Drive.
And since Google Drive will automatically synchronize with your desktop folders, the saved email attachments will instantly download and become available on your local disk as well for offline viewing.

Save Gmail Attachments in Google Drive

You don’t have to install any extensions and the technique will work just fine in the web and mobile version of Gmail (including any of your Gmail Apps that support labels).
Gmail to Google Drive

Setting the Stage

If you would like to have a similar setup for your Gmail and Google Drive, all you need is a minute. Just follow these easy steps:
  1. Assuming that you are logged in to your Google account, create a copy of this sheet in your Google Docs (now Google Drive).
  2. Open the sheet and you should see a new Gmail menu – click Initialize and grant the necessary permissions. This is your sheet (see source code) and you are not sharing your Google credentials or data with anyone else.
  3. Next go the Gmail menu again and select Run. Close the Google sheet and you are done.

Behind the Scene

Here’s how the program works. The Google sheet will monitor your Gmail mailbox in the background (every two minutes) and as soon as it finds any message that has a label GoogleDrive, it will automatically save all the attachments in that message to the Gmail folder on your actual Google Drive.
Once the basic setup is ready, apply the label GoogleDrive to any of your email messages in Gmail and the attached files should become available in your Drive (both online and offline) in the next few minutes.

Troubleshooting tips

If you are getting errors like “Service invoked too many times,” you can increase the trigger duration. Open the same sheet in Google Docs, go to Tools –> Script Editor and then choose Resources –> Current Script Triggers. Change the value of Minutes timer from “Every 5 minutes” to say “Every 15 minutes”.
If you would like to stop the script from running in the background, go to the same trigger screen and simple delete the “SendToGoogleDrive” time trigger.
Alternatively, you can also follow the manual route to save attachments in Docs.