Gmail2GDrive is a Google Apps Script which automatically stores and sorts Gmail attachments into Google Drive folders.
It does so by defining a list of rules which consist of Gmail search filters and Google Drive destination folders. This way the attachments of periodic emails can be automatically organized in folders without the need to install and run anything on the client.
- Automatically sorts your attachments in the background
- Filter for relevant emails
- Specify the destination folder
- Rename attachments (using date format strings and email subject as filenames)
- Open Google Apps Script.
- Create an empty project.
- Give the project a name (e.g. MyGmail2GDrive)
- Replace the content of the created file Code.gs with the provided Code.gs and save the changes.
- Create a new script file with the name 'Config' and replace its content with the provided Config.gs and save the changes.
- Adjust the configuration to your needs. It is recommended to restrict the timeframe using 'newerThan' to prevent running into API quotas by Google.
- Test the script by manually executing the function performGmail2GDrive.
- Create a time based trigger which periodically executes 'Gmail2GDrive' (e.g. once per day) to automatically organize your Gmail attachments within Google Drive.
Direct any feedback and contributions directly to Github.
I'd like to thank Amit Agarwal who provided similar functionality in his article Send your Gmail Attachments to Google Drive from which Gmail2GDrive evolved to provide more flexibility.