Steps
Create an app password
Gmail and Outlook require 2-step verification plus an app password for IMAP. Your normal password won't work.
Download the agent
Get the attachment saver agent and try it on the bundled sample emails:
python3 attachment_saver.py --eml-dir sample_emails --dry-run.Pick what to save
EXTENSIONS=pdf,xlsx,csvandFROM_CONTAINS=invoice,billing@keep only what matters.DAYS=7sets how far back to look.Choose the folder
Set
SAVE_DIRto a Dropbox, OneDrive or Google Drive synced folder and your attachments end up in the cloud too.Run hourly
0 * * * *in cron. Files that were already saved are skipped.
Safe by design
The script only reads mail. It never deletes, moves or marks emails as read. Your password stays in a local .env file on your own machine.
Skip the setup: free download
The Attachment saver agent does all of this. It's tested, MIT-licensed, and comes as an n8n workflow plus a Python script.
Get the free Attachment saver agent → Or have us build yours →
FAQ
Does it work with Outlook / Microsoft 365?
Yes, if IMAP is enabled for your account: IMAP_HOST=outlook.office365.com.
Can I save to Google Drive directly?
In n8n Cloud, replace the write-to-disk node with the Google Drive upload node.
Related guides
- Forward emails to a Discord channel (Gmail, Outlook, any IMAP)
- Forward emails to a Slack channel (Gmail, Outlook, any IMAP), free with an incoming webhook
- Forward emails to Telegram (Gmail, Outlook, any IMAP), free and no bot hosting
- n8n Email Trigger attachments: fix attachment_0 and "none was found", 12 tests
- n8n Gmail Trigger not working: not firing, silent errors and fixes
New guides
- GitHub release notifications in Slack (any public repo, stable releases only)
- Send RSS feeds to Slack with a keyword filter (free, incoming webhook)
- n8n Google Sheets Trigger not working: not firing, activation errors and fixes
- n8n Google Drive Trigger not working: not firing, activation errors and fixes