Gmail Email Archiving and Structured Export to Google Drive CSV - n8n Workflow

Use this robust n8n workflow template to automatically export specific Gmail messages, parse key data points, convert them to CSV, and save the resulting file securely to Google Drive.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users requiring compliance or audit archives of specific email threads.
Professionals who need to export filtered email reports into a structured format.
Teams leveraging powerful n8n templates for automated data backup and centralization.
Anyone looking for a complete, structured email export n8n workflow solution.

Overview

This comprehensive n8n automation provides a structured and efficient way to handle email data extraction and archiving. Organizations frequently need to move specific email streams—such as vendor invoices, client reports, or internal audit logs—from Gmail into a structured, storable format like CSV for long-term retention or analysis. This n8n workflow template solves this challenge by automatically querying emails based on sender filters, extracting critical data points (subject, body, time), standardizing the timestamp using a custom n8n node, converting the resulting structured data into a clean CSV file, and storing it securely in Google Drive. Utilizing this n8n template saves significant manual effort and ensures data integrity during the archiving process.

How it Works

This n8n workflow is designed for manual execution, ensuring flexibility in when the archive is generated.


  1. Start and Fetch: The automation begins with the Start Workflow manual n8n trigger.

  2. Gmail Retrieval: The Gmail n8n node executes an 'Get All' operation, specifically querying the account for messages originating from a predefined sender (configured in the filter settings).

  3. Data Parsing: The Parse Data Set n8n node then isolates and maps the critical data fields from the Gmail output: email ID, subject, body text (text), and the raw timestamp (date).

  4. Time Standardization: The Convert Time Field Code n8n node takes the extracted timestamp and applies a custom JavaScript snippet. This snippet localizes the time field to a specific timezone (defaulting to Asia/Kolkata in this n8n workflow, which should be updated) and formats it for human readability.

  5. File Conversion: The Convert to File n8n node transforms the structured JSON array containing the email data into a file payload, preparing it for upload (it defaults to generating a CSV output).

  6. Google Drive Upload: Finally, the Google Drive n8n node takes the converted file and uploads it to the root folder. The file is given a unique name based on the execution time (e.g., {{ $now + "n8nexport.csv" }}), concluding the n8n workflow execution.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. Gmail Credentials: Set up or select your Gmail OAuth2 credentials for the Gmail n8n node.

  3. Google Drive Credentials: Set up or select your Google Drive OAuth2 credentials for the Google Drive n8n node.

  4. Configuration (Gmail): In the Gmail n8n node, update the sender filter parameter to match the specific email address you wish to archive.

  5. Configuration (Code): In the Convert Time Field Code n8n node, review the JavaScript code and update the timeZone setting to reflect your local or required archiving timezone (e.g., change Asia/Kolkata to America/New_York).

  6. Configuration (Google Drive): Optionally, update the Google Drive n8n node to specify a non-root folderId for dedicated archiving, or change the output filename template.

  7. Testing: Execute the Start Workflow n8n trigger manually to test the flow.

Node Details

Start Workflow (Manual Trigger): The initiating n8n trigger for the automation, allowing manual execution.
Gmail (Gmail n8n node): Fetches all emails filtered by a specific sender ([email protected]). Key configuration: Operation: getAll, filtered by sender.
Parse Data (Set n8n node): Extracts and maps relevant data points into a clear structure: id, subject, message (mapped from text), and time (mapped from date). This ensures data consistency before conversion.
Convert Time Field (Code n8n node): A custom n8n node responsible for time zone localization and formatting, making the timestamp readable and accurate for the archive.
Convert to File (n8n node): Transforms the structured JSON items into a single file payload, essential for exporting data. This is configured to output the data required for the final CSV file.
Google Drive (Google Drive n8n node): The final action n8n node, configured to create a file using a dynamic name (timestamp prefix) and upload the archived CSV content to the specified Google Drive folder (defaults to 'My Drive').

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all

Featured*