Gmail has no rule to save attachments to Drive automatically. A short Google Apps Script can do it for free. Choose your options below, copy the script, paste it into Apps Script and set a timer. Nothing is sent to us: the script runs only in your Google account.
Works with personal Gmail and Google Workspace · Gmail only (for Outlook or IMAP, see the end of the page)
Same syntax as the Gmail search box. Examples: has:attachment from:billing@supplier.com, has:attachment subject:invoice, has:attachment label:clients-acme. The script adds the "already saved" filter for you.
Created in My Drive if it does not exist.
The part after /folders/ in the folder's URL. Use it for shared drives.
Comma separated. Empty = every file type.
Filters out logos and signature images.
Used so nothing is saved twice.
Go to script.google.com with the Google account whose Gmail you want to read, and click New project. Rename it, for example "Gmail attachments to Drive".
Delete the sample myFunction code in Code.gs, paste the script and save (Ctrl/Cmd + S).
In the function menu at the top choose saveAttachments and click Run. Google asks for permission to read Gmail and manage Drive. Because it is your own script, Google shows "Google hasn't verified this app": click Advanced → Go to (project name) → Allow. Check the execution log and your Drive folder.
Choose installTrigger in the function menu and click Run. From now on the script runs automatically at the interval you picked. To stop it, run removeTrigger or delete the trigger in the clock icon (Triggers) on the left.
saveAttachments a few times by hand, or let the timer catch up.Honest limits you should know about:
| This Apps Script | Inbox2Drive | |
|---|---|---|
| Price | Free | Free up to 10 documents/month; from €19/month |
| Mailboxes | The Gmail account it runs in | Gmail, Outlook/Microsoft 365, any IMAP; several into one Drive |
| Sorting | By the search you write, sender or month | AI reads each file: invoice, receipt, contract, payslip… (13 types) |
| Past emails | Whatever your search finds, 50 conversations per run | Historical import (up to 24 months on Pro) |
| Destination | Google Drive | Google Drive, OneDrive or Dropbox |
| Upkeep | You maintain the code | None |
If the script covers your needs, use it: it is a good solution for one Gmail account and simple rules. If you need several inboxes, Outlook, or documents filed by type without writing a search for each, try Inbox2Drive free. More options compared in all 5 ways to save email attachments to Google Drive.
Not on its own. Gmail lets you save one attachment at a time with the Drive icon, but it has no rule that does it automatically. A Google Apps Script on a time trigger, a Gmail add-on, an automation platform or a dedicated tool can do it.
Yes. Apps Script is included with every Google account. The script runs inside your own account, so your emails and files are not sent to us or anyone else. Google applies daily quotas, which are enough for most small inboxes.
After processing a conversation it adds a Gmail label (for example SavedToDrive) and the search excludes conversations with that label. Labels apply to whole conversations, so attachments in a reply that arrives later in an already labeled conversation are skipped.
Scripts you write yourself are not reviewed by Google, so the consent screen shows a warning. Because you are the author and the only user, you can click Advanced and continue to the project. Only authorize scripts whose code you have read.
Yes: paste the shared drive folder's ID in the "folder ID" field. Your account needs permission to add files to that folder.
No. Apps Script can only read the Gmail account it runs in. For Outlook see how to save Outlook attachments to Google Drive.
Related: All free tools · all 5 ways compared · Zapier alternative · cloudHQ alternative · Gmail add-ons compared · download all Gmail attachments at once · versión en español · for bookkeepers.
Inbox2Drive connects Gmail, Outlook and IMAP, reads each attachment with AI and files it in the right Drive folder. Never sends or deletes your email.
Create a free accountFree plan · No credit card required