How to Automate Cold Email Outreach Using N8N +Google Sheet +Gmail

How to automate cold email outreach using n8n +google sheet +gmail

Sending personalized bulk emails has never been easier — thanks to n8n + Google Sheets! In this step-by-step guide, I’ll show you how to build a fully automated cold email system using either Gmail or your custom SMTP, while logging every email’s status back into your Google Sheet in real time.

🔧 What’s Included in This Guide:

  • ✅ Ready-to-use n8n workflow JSON files (for Gmail & SMTP)
  • 🧠 JavaScript snippets for dynamic content and personalization
  • ⏱ Built-in delay mechanism to prevent spam flags
  • 📊 Real-time email status and timestamp logging

✅ Requirements

To get started, you’ll need:

  • A free n8n instance (self-hosted or n8n cloud)
  • A Google account with access to Google Sheets
  • Gmail or SMTP email access
  • A Google Sheet with:
    • Sheet 1: List of leads (Name, Email)
    • Sheet 2: Email templates (Subject, Body)

📂 Download Resources

  • 🔽 Download Workflow (Gmail Node): [Download]
  • 🔽 Download Workflow (SMTP Node): [Download]

🧩 JavaScript Snippets

🎯 Random Template Selector

jsCopyEditconst templates = items.map(item => item.json);

if (!templates || templates.length === 0) {
  throw new Error('No templates found');
}

const index = Math.floor(Math.random() * templates.length);
const template = templates[index];
const bodyHtml = template.Body.replace(/\n/g, '<br>');

return [{
  json: {
    subject: template.Subject,
    body: bodyHtml
  }
}];

🙋‍♂️ Name Personalization (Set Node)

jsCopyEdit{{ $json.body.replace("[name]", $json["Name"] && $json["Name"].trim() !== '' ? $json["Name"].trim() : "there") }}

📬 Send Status Detection

Gmail Version:

jsCopyEdit{{ $json.labelIds[0] }}

SMTP Version:

jsCopyEdit{{ $json.response.includes("250 2.0.0 Ok") ? "SENT" : "Failed" }}

⏱ Timestamp Logging (Asia/Kolkata timezone)

jsCopyEdit{{ new Date().toLocaleTimeString("en-GB", { timeZone: "Asia/Kolkata", hour12: false }) }}

📊 Workflow Overview

Here’s what this automation does:

  1. 📋 Fetches leads from Sheet 1 (Name + Email)
  2. 📨 Fetches email templates from Sheet 2
  3. 🎲 Randomly selects one template
  4. 🧩 Replaces variables like {{name}} in the email body
  5. ✉️ Sends the email using Gmail or SMTP
  6. ✅ Logs send status and timestamp back into Google Sheets
  7. ⏱ Waits for a short delay before sending the next email to prevent spam issues
SHARE :
Facebook
Twitter
LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *

ABOUT ME
Gb khaan (1)
Written By

GB Khaan

MORE INFO
Call Us

+966 59 8040 226

Location

Saudi Arabia