Home › Guides › n8n: Gmail attachments to Google Drive
Guide · n8n · Gmail · Google Drive

How to save Gmail attachments to Google Drive with n8n (step by step)

Last checked: 25 November 2026

Short answer: use three nodes. A Gmail Trigger with Simplify turned off and Download Attachments on, a Split Out node on $binary so each attachment (attachment_0, attachment_1…) becomes its own item, and a Google Drive node with File › Upload. Below is the exact setup, the pitfalls that break it after a week, and when a dedicated tool is simpler.

Free plan, no card · Never sends or deletes email · Only attachments are saved

Before you start: n8n Cloud or self-hosted

The workflow is the same on both. What changes is the Google connection and who runs the server.

The workflow, step by step

Gmail Trigger  →  Split Out ($binary)  →  Google Drive (File › Upload)
  1. Gmail Trigger: poll for new mail

    Add a Gmail Trigger with your Google credential. Under Poll Times choose a mode such as Every X (for example every 5 minutes) or Custom. The event is Message Received.

    In Filters, narrow it down: Search accepts Gmail search syntax, for example has:attachment filename:pdf, and you can also filter by Label Names or IDs or Sender. Max Emails per Poll defaults to 10 (maximum 50); extra matches wait for the next poll.

  2. Turn Simplify off, then enable Download Attachments

    This is the step most tutorials skip. Simplify is on by default, and while it is on the Options collection is hidden. Turn Simplify off, then add Options › Download Attachments (default off) and switch it on. Leave Attachment Prefix at its default attachment_: n8n appends an index starting at 0, so an email with three files produces binary properties attachment_0, attachment_1 and attachment_2 on a single item.

  3. Split Out: one item per attachment

    The Google Drive upload reads one binary property per item, so split them first. Add a Split Out node and set Field to Split Out to $binary. It outputs one item per binary property, and each item keeps its original key (attachment_0, attachment_1…). Set Include to All Other Fields if you want the email's subject and sender available downstream.

  4. Google Drive: File › Upload

    Add a Google Drive node, Resource File, Operation Upload. Because the property name differs per item, use expressions:

    Input Data Field Name:  {{ Object.keys($binary)[0] }}
    File Name:              {{ $binary[Object.keys($binary)[0]].fileName }}
    Parent Drive:           My Drive
    Parent Folder:          (pick your folder: From list / By URL / By ID)

    Run it once with a test email, check the file in Drive, then activate (publish) the workflow so the trigger starts polling.

Alternative to Split Out: a Code node

If you prefer every item to carry its file under the usual data name (so the Drive node can use data as Input Data Field Name and {{ $binary.data.fileName }} as File Name), replace Split Out with a Code node set to Run Once for All Items:

const out = [];
for (const item of $input.all()) {
  for (const [key, file] of Object.entries(item.binary ?? {})) {
    out.push({
      json: { ...item.json, attachmentKey: key, fileName: file.fileName },
      binary: { data: file },
    });
  }
}
return out;

Common pitfalls (and how to avoid them)

1. The connection dies after 7 days

On self-hosted n8n, if your OAuth consent screen uses the External user type, the app starts in Testing mode. Only accounts you add as test users can sign in, and both n8n's docs and Google's OAuth documentation say refresh tokens in that state expire after 7 days. Your workflow then fails silently until you reconnect. Fixes: use an Internal app if you are on Google Workspace, publish the app, or reconnect the credential when it expires. Also make sure the Gmail API is enabled in the project; n8n lists a 401 "Client is unauthorized" error as the typical symptom when it isn't.

2. Emails you already opened are skipped

The trigger's Read Status filter defaults to Unread emails only. If you read an invoice on your phone before the next poll, it may never trigger. For filing, set it to Unread and read emails.

3. Polling, not push

The Gmail Trigger polls on your schedule; it is not instant. On n8n Cloud, each poll that finds mail runs the workflow, and each run counts as an execution, so a short interval plus a busy inbox adds up.

4. Duplicates

The trigger keeps a timestamp cursor and remembers message IDs at the boundary to avoid delivering the same email twice. Duplicates still appear in practice when you re-run executions by hand, run a backfill that overlaps the live trigger, or copy the workflow. Google Drive happily stores two files with the same name. Common guards: add a Gmail node (Message › Add Label, e.g. saved-to-drive) after the upload and exclude it in the trigger search with -label:saved-to-drive, or search the folder for the file name before uploading.

5. Old emails are not backfilled

Looking at n8n's source code, the trigger's first poll starts from the current time, so only mail arriving after activation is processed. A manual test run returns just the latest matching message. For history, build a separate workflow: Manual Trigger → Gmail node, Message › Get Many, Simplify off, Download Attachments on, a Search like has:attachment and Received After/Received Before dates → the same Split Out and Drive nodes. Get Many returns 50 messages by default (Limit can go up to 500, or use Return All), so work through large mailboxes in date ranges.

6. Everything lands in one folder

The workflow above saves files flat. Sorting by supplier, year or document type means adding IF/Switch nodes, folder lookups or an AI step, and maintaining those rules yourself.

When n8n is the right tool, and when it isn't

n8n is a great fit if you are a developer or ops person who wants custom logic: post a Slack message when a contract arrives, parse invoice fields into a database, rename files with your own scheme, or chain this into a bigger automation. Self-hosting keeps data on your own server.

A dedicated tool is simpler if the goal is just "every attachment, filed in the right folder, without thinking about it". That is what Inbox2Drive does:

n8n workflowInbox2Drive
SetupGoogle OAuth (self-hosted), 3+ nodes, expressionsConnect mailbox and storage
Old emailsSeparate Get Many workflowIncluded
Folder sortingWhatever you buildAutomatic, by AI
MailboxesGmail node (other nodes for IMAP/Outlook)Gmail, Outlook, IMAP
MaintenanceYoursNone on your side
Custom logicUnlimitedFocused on saving attachments

What Inbox2Drive doesn't do: it only saves attachments. It never sends or deletes your emails. There is a free plan with no card required.

Connect Gmail for free

Comparing other automation tools? Read our Zapier alternative for email attachments to Google Drive, the Power Automate alternative to save email attachments, or why a Gmail filter alone can't save attachments to Drive.

Frequently asked questions

Can n8n save Gmail attachments to Google Drive?

Yes. Use a Gmail Trigger with Simplify turned off and the Download Attachments option on, split the attachments into separate items with a Split Out node on $binary (or a Code node), and upload each one with the Google Drive node's File › Upload operation.

Why don't I see the Download Attachments option in the Gmail Trigger?

The Options collection that contains Download Attachments and Attachment Prefix only appears when Simplify is turned off. Simplify is on by default.

Why does my n8n Google connection stop working after a week?

On self-hosted n8n with your own Google OAuth app, an External app in Testing publishing status gets refresh tokens that expire after 7 days. Reconnect the credential, use an Internal app on Google Workspace, or publish the app. n8n Cloud users can use n8n's managed OAuth instead.

Does the n8n Gmail Trigger process old emails?

No. On its first poll the trigger starts from the current time, so it only picks up mail that arrives after the workflow is active. For older emails, run a separate workflow with the Gmail node's Message › Get Many operation, a search such as has:attachment and Download Attachments enabled.

Is there a simpler way than n8n to save Gmail attachments to Drive?

If you don't need custom logic, a dedicated service such as Inbox2Drive connects Gmail, Outlook or IMAP, processes past and new attachments, classifies them with AI and saves them into folders in Google Drive, OneDrive or Dropbox, with nothing to host or maintain. It has a free plan with no card.

Questions about your setup? Email marketing@inbox2drive.com and we'll help you by email.

Sources

Last checked: 25 November 2026 against n8n's official documentation, its public source code and Google's developer documentation. Node options and plan limits change between versions; follow the links for the current wording.

Want the result without building the workflow?

Connect Gmail on the free plan, pick Google Drive, OneDrive or Dropbox, and let past and new attachments land in the right folder on their own.

Create a free account

Free plan, no card · Never sends or deletes email · Help by email at marketing@inbox2drive.com

Related