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.
Download this n8n workflow template and start using it instantly.
Accounting teams handling incoming invoices or receipts.
Businesses needing automated vendor file organization based on a predefined whitelist.
Users looking for advanced examples of n8n templates integrating multiple services.
Anyone needing a reliable n8n workflow to automatically move and categorize data between Gmail, Google Sheets, and Google Drive.
Managing incoming attachments, especially high-volume items like invoices or receipts, can be tedious and prone to manual error. This powerful n8n workflow solves the problem of manual filing by providing an automated, smart categorization system. It leverages a Google Sheets whitelist (defined by the Lookup in Sheets n8n node) to map sender emails to specific company names.
When a new email matches the criteria set in the n8n trigger, the n8n workflow executes a series of intelligent file management actions: dynamically searching for the corresponding Company folder, and then creating a nested YYYY/MM folder structure within that company's directory if it doesn't exist. This complex organizational logic is handled seamlessly by the subsequent n8n node configuration, ensuring every attachment is downloaded, split, and stored correctly in Google Drive, prefixed with a timestamp for unique identification. This is a crucial and robust n8n workflow for improving document management and operational efficiency.
The n8n automation starts with the Gmail Trigger n8n node, which constantly polls for new emails matching a predefined Gmail filter (e.g., having a specific label, often applied to emails containing attachments or keywords like 'invoice').
Lookup in Sheets n8n node to fetch the corresponding company name from a Google Sheets whitelist.Search Company Folder1 n8n node. If the folder for that company doesn't exist, the Create Company Folder n8n node generates it under a specified parent folder.YYYY/MM n8n node dynamically calculates the current year/month folder name based on the email date. The n8n node Search For Folder checks for this folder inside the company directory. If missing, Create Month Folder generates it.Gmail n8n node downloads the attachments from the triggered email.Split Up Binary Data1 Function n8n node. This essential step transforms the single input item (containing all files) into multiple items, one for each attachment, preparing them for the batch upload loop.Upload To Folder n8n node saves each individual file, prefixed with a timestamp, into the correct nested Google Drive folder ID determined earlier. This reliable n8n workflow ensures organized archiving.Gmail Trigger n8n node and the Gmail n8n node. Ensure your account is authorized to read the necessary labels.email and company columns. Update the Lookup in Sheets n8n node with the correct Document ID and Sheet Name.Create Company Folder n8n node, currently set to 'Invoices').Gmail Trigger n8n trigger is correctly configured to monitor the label you are using for filtered emails (e.g., Label_2). Gmail Trigger (n8n trigger): Monitors Gmail via polling (every 15 minutes). It is filtered to process only emails associated with a specific label (Label_2). This n8n trigger initiates the entire automation.
Lookup in Sheets (Google Sheets n8n node): Queries a Google Sheets document based on the sender's email address to retrieve the associated company name, which is crucial for folder naming.
Search Company Folder1 / Create Company Folder (Google Drive n8n node): Manages the top-level company folder. It searches for the company folder using the name retrieved from Google Sheets and creates it if it does not exist, storing it under a predefined parent folder ID.
YYYY/MM (Set n8n node): A logic n8n node that uses an expression to dynamically format the date from the email into a YYYY/MM string for folder naming (e.g., 2024/07).
Gmail (Gmail n8n node): Performs the get operation on the triggered message ID. Key configuration includes enabling downloadAttachments: true, essential for passing file data down the n8n workflow.
Split Up Binary Data1 (Function n8n node): This custom code n8n node takes the attachments downloaded by the Gmail n8n node and splits them into separate items, ensuring that the subsequent Upload To Folder n8n node processes each attachment individually.
=data) to the dynamically determined folder ID (which could be the search result ID or the newly created folder ID), ensuring files are stored correctly with a unique timestamp prefix.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 powerful n8n workflow to automate e-commerce order processing. Integrate a webhook n8n trigger with Google Sheets for real-time inventory checks and send instant stock alerts via Slack. Find more n8n templates for logistics.

Automate Gmail attachment saving to Google Drive using a robust n8n workflow. It creates sender-specific folders, ensures perfect organization, and avoids duplicates.

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.


IT professional and n8n enthusiast







































