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 in 'Gmail attachments' folder, * */ function saveEmailAttachmentsToDrive(){ // Create 'Gmail Attachments' folder if not exists. createFolder_('Gmail attachments'); // Get inbox threads starting from the latest one to 100....