Downloading Gmail attachments to Drive

The saveEmailAttachmentsToDrive function can download Gmail attachments to Drive. In this function PropertiesService is used to avoid repeated downloading of the same attachment. The createFolder_ function is used to create folders, if not already exist, with the given name in Drive.

Tip

If any function name is appended with _, then it will not be listed under the Run menu. You cannot run these functions directly, but they can be called from the other functions. These are called private functions.

You can create the createFolder_ function in the same script file along with the saveEmailAttachmentsToDrive function or in a separate script file such as Library.gs:

/** * Checks latest 100 inbox threads, * saves attachments ...

Get Learning Google Apps Script now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.