What This Workflow Does
This workflow helps you take email attachments sent to you and puts them into your Google Drive automatically.
It checks for new unread emails from a chosen sender, downloads each attachment separately, sorts files by size, and uploads medium or large files to a folder in Google Drive.
This saves time and stops you missing or losing files by handling everything without clicking yourself.
Tools and Services Used
- Gmail Account: To watch for new emails and download attachments.
- Google Drive Account: To store files uploaded automatically.
- n8n Automation Platform: To build and run the workflow managing all steps.
- OAuth2 Credentials: Needed for secure access to Gmail and Drive inside n8n.
Input → Processing → Output
Input
- New unread emails in Gmail from a specific sender with file attachments.
Processing
- Trigger when such emails arrive.
- Split attachments to handle one by one, no matter their filename.
- Check each file’s size to decide what to do next.
- Send medium and large files to Google Drive upload.
- Take special actions for files too big or too small as needed.
Output
- Files correctly uploaded to Google Drive folder per size category.
- Notifications or skips for files outside upload size range.
Beginner Step-by-Step: How to Use This Workflow in n8n
Step 1: Import the Workflow
- Download the workflow file using the Download button on this page.
- Open your n8n editor, then click “Import from File” and select the downloaded workflow.
Step 2: Set Up Required Credentials
- Add your Gmail and Google Drive credentials with OAuth2 authentication if not done already.
Step 3: Update Workflow Settings
- Change email address filter to your sender if needed, inside the Gmail Trigger node.
- Update folder ID in the Google Drive node to match your preferred storage folder (replace the example ID).
Step 4: Test the Workflow
- Send yourself a test email with different size attachments from the configured sender address.
- Run the workflow manually or wait for the trigger to activate and check the results.
Step 5: Activate for Production
- Switch the workflow to Active mode in n8n so it runs automatically on new email arrivals.
- Make sure your n8n instance runs continuously or is set to poll Gmail frequently.
If hosting n8n yourself, visit self-host n8n for smooth running advice.
Detailed Workflow Structure
Trigger and Attachment Extraction
The Gmail Trigger node checks Gmail for new unread emails from a specific sender. It downloads attachments immediately.
The Split Out node takes all attachments and makes each file one item in the process. This is important to handle files one by one, no matter their names.
File Size Categorization
The Switch node examines each attachment’s size property.
Files are placed into three categories: large (over 300MB), medium (between 10MB and 300MB), and small (under 10MB).
Upload and Notification Actions
Medium files trigger a Google Drive upload node to save files in the specified folder using the original filename.
Large files connect to a NoOp node simulating a notification or alert for manual handling.
Small files connect to another NoOp node that ignores them (like icons or tiny images).
Common Problems and Fixes
- No attachments found: Check if the Gmail Trigger filters use the correct sender’s email and that downloadAttachments is enabled.
- Uploads fail: Verify Google Drive folder ID and OAuth2 credentials are accurate and current.
Workflow Customization Ideas
- Change sender email filter to track attachments from other email addresses.
- Modify the file size limits in the Switch node to fit storage or upload needs.
- Replace NoOp notification nodes with real email or Slack alerts for large files.
- Build logic to choose Google Drive folder based on attachment metadata dynamically.
Summary
✓ This workflow automatically moves email attachments from specific senders to Google Drive by file size.
✓ It saves hours by removing the need to manually download or upload attachments.
✓ Users avoid mistakes like lost files or wrong file placements.
→ Files are sorted into large, medium, or small and handled accordingly.
→ Medium and large files go into Drive, large files alert the user, and small files are ignored.
