Auto-Save Gmail Attachments to Google Drive Without Lifting a Finger
Automatically detects new Gmail emails with attachments and saves them directly to a specified Google Drive folder. No more manual downloading and uploading — every attachment lands in Drive the moment it arrives.
- 1
Trigger on new Gmail emails
Add a
Gmail Triggernode. SetEventtoMessage Received. UnderFilters, enableHas Attachmentso the workflow only fires when an email actually includes a file. Connect your Gmail account via OAuth2 in theCredentialfield. The node polls every minute by default — you can adjust the interval inPoll Time. - 2
Filter out emails with no attachments
Add an
IFnode connected to the Gmail Trigger. SetConditionto check that{{ $json.attachments }}exists and has a length greater than 0. Route theTruebranch forward. This acts as a safety net in case the trigger picks up edge-case emails. - 3
Extract attachment binary data
Add a
Setnode on theTruebranch. Create a field namedfileNamewith the value{{ $json.attachments[0].name }}. This captures the original filename so Google Drive can use it when saving. Keep all other fields as-is. - 4
Upload the file to Google Drive
Add a
Google Drivenode set toOperation: Upload. InFile Name, enter{{ $node["Set"].json["fileName"] }}. SetInput Data Field Nametodata(the binary field the Gmail Trigger populates). UnderParents, paste the ID of the destination folder from your Drive URL (the string after/folders/). Connect your Google account via OAuth2 inCredential.
Frequently asked questions
How do I find my Google Drive folder ID?
Open the destination folder in Google Drive in your browser. The URL will look like `https://drive.google.com/drive/folders/FOLDER_ID_HERE`. Copy the long string of letters and numbers after `/folders/` and paste it into the Google Drive node's `Parents` field.
Will this save all attachments if an email has more than one?
The basic workflow saves the first attachment. To handle multiple attachments, add a `Split In Batches` node between the Set and Google Drive nodes and loop over `$json.attachments`. For most users, single-attachment handling covers the majority of use cases.
Is my Gmail data safe passing through n8n?
If you run n8n on your own server (self-hosted), data never leaves your infrastructure. If you use n8n Cloud, data is processed on n8n's servers in transit but not stored. Always use OAuth2 credentials rather than passwords for the safest connection.