Emails can already be organized well in Gmail by assigning labels and grouping them into one or more topics. The following script goes one step further and automatically stores additionally labeled emails in specific folders in Drive. The emails are stored once as a PDF or, if attachments are present, as a ZIP file. This automation makes it even easier to keep up with your most important files. At the same time, other users can be given access to information stored in Drive.
The only thing left for you to do is label emails, deposit folders in Drive and run the script.
You can download the script here.
Application
To run the script,
- Click Publish -> Set up as web app in the menu
- Under Execute the app as: you can select under which authorization the application should run. In this case, select User accessing the web app.
- Under Who has access to the app: you can limit the visibility of the app to your organization by selecting Anyone within....
- Then the app can be accessed at the specified URL (Current web app URL:) and shared with appropriate people or the organization.
In the opened window, the label assigned in Gmail and the folder can now be selected as the storage location under the New Rule section. It is possible to run the script once, with the saved emails limited to a number of five per execution, or automated every five minutes. The automation can be stopped at any time. The executed rule is removed by clicking x.
The limitation to 5 emails per run is stored because a maximum of 1500 documents (PDFs) can be created in Google Drive per day. If the script runs every 5 minutes and you want to store several 10,000 emails in Google Drive, this is possible, as "only" 1440 documents are created per day this way.
All steps are documented again under the blue information icon.
Already saved emails are marked in Gmail with a label (default name: "#"). In the script under Code.gs, section Globals, the label name for the already saved emails can be customized:
Do you have any questions or suggestions? Feel free to contact us!