Automate Gmail attachment saving to Google Drive using a robust n8n workflow. It creates sender-specific folders, ensures perfect organization, and avoids duplicates.
Download this n8n workflow template and start using it instantly.
System Administrators & Integrators: Seeking reliable n8n templates for email processing.
Virtual Assistants & Solopreneurs: Managing high volumes of incoming documents and files.
Automation Specialists: Looking for a sophisticated n8n workflow example utilizing conditional logic and recursion.
Anyone needing automatic, organized archival of email attachments based on the sender.
Managing email attachments manually can be time-consuming and lead to disorganized cloud storage. This robust n8n workflow solves this by providing a completely automated solution for filtering, extracting, and organizing files from Gmail directly into Google Drive.
This specific n8n automation is designed for meticulous organization. When a new email arrives, the n8n node determines the sender's email address and uses it as the folder name. Crucially, before creating a new folder, the n8n workflow uses a Google Drive node to check if a folder for that sender already exists. If it exists, the files are placed inside; if not, a new folder is created on the fly. This sophisticated conditional logic, combined with a recursive Execute Workflow n8n node structure for efficient batch processing, ensures your Google Drive stays clean, structured, and free of duplicate folders. This powerful n8n node setup provides exceptional reliability for file management.
This comprehensive n8n workflow uses a nested structure for efficient processing:
Gmail Trigger n8n trigger, which constantly monitors your inbox for new messages. For manual testing, the Manual Trigger initiates the flow, fetching emails using the Get emails n8n node.Loop Over Items (Split in Batches) n8n node combined with an Execute Workflow n8n node, executing itself recursively for each email. This isolates processing and improves reliability.Get email n8n node retrieves the full email body and downloads all associated attachments (binary data).If n8n node (Contain attachments?) checks if any binary data exists. If not, the processing stops for that item.Search folders Google Drive n8n node searches the designated parent folder for a sub-folder matching the sender's email address.Exist? n8n node determines the path: if the folder exists, the flow proceeds to the Folder ID n8n node to capture the existing ID. If it does not exist, the Create folder n8n node creates a new folder using the sender's email as the name.Get attachments custom Code n8n node processes the complex binary data structure from Gmail, mapping each attachment into a usable format with its filename, preparing it for upload.Upload attachment Google Drive n8n node executes, placing the file into the dynamically determined sender-specific folder. This complete n8n workflow provides fully automated organization.To install this n8n workflow and start using these n8n templates, follow these steps:
Search folders and Create folder n8n nodes, ensure the folderId is set to your desired parent folder (e.g., 'Email Attachments') where the sender-specific folders will reside.Gmail Trigger n8n trigger for continuous, automatic execution, or use the manual trigger for initial testing. Gmail Trigger: This essential n8n trigger polls your Gmail inbox for new emails. It is configured to run every minute (everyMinute).
Get emails (Gmail n8n node): Used in the manual path to fetch emails. Key configuration: operation: getAll with downloadAttachments: true.
Get email (Gmail n8n node): Fetches the full email details based on the message ID from the preceding item. Also ensures downloadAttachments: true.
Contain attachments? (If n8n node): A core logic n8n node that checks if the $binary object is not empty, filtering out emails without files.
Search folders (Google Drive n8n node): Searches the parent directory using the sender's email address (={{ $('Get email').item.json.from.value[0].address }}) as the search query. It limits results to 1 (limit: 1).
Exist? (If n8n node): Checks the output of the Search folders n8n node. If the output JSON is not empty, the folder exists.
Create folder (Google Drive n8n node): Creates a new folder. The folder name is dynamically set using the sender's email address.
Get attachments (Code n8n node): This custom n8n node iterates through the raw binary keys provided by the Gmail n8n node and restructuring the data so that each attachment is an individual item ready for the Upload attachment n8n node.
folderId is dynamically pulled from the result of the Folder ID or Create folder n8n nodes, ensuring files land in the correct sender folder.Use this efficient n8n workflow to automatically download Gmail attachments, lookup sender companies in Google Sheets, and organize files into year/month folders in Google Drive.

Automate saving Gmail attachments to organized Google Drive folders. Use this robust n8n workflow to handle email subjects and creation dates for structured storage using the n8n node architecture.

Use this powerful n8n workflow to automatically analyze creative assets, check brand compliance, generate rich metadata, and log results to a Google Sheets dashboard using the ScrapeGraphAI n8n node.

Use this advanced n8n workflow to automatically categorize Gmail emails with GPT-4, detect urgency, and send instant alerts via Telegram and WhatsApp using a custom n8n node setup.

Automate school email organization using this sophisticated n8n workflow. AI classifies emails (schedules, notices, contacts) for seamless integration with Google Calendar and Drive, utilizing specific n8n node logic.

Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at [email protected] or add me on Linkedin.com/in/davideboizza







































