|

How to Use Google Apps Script to Send Automated Custom Emails from Google Sheets

Learning how to send automated emails from google sheets is the single most valuable workflow automation any business owner or knowledge worker can master. Instead of paying $30 to $100 per month for third-party mail merge extensions or marketing email software, you can build a 100% free email automation for small business system using Google Apps Script and your standard Google account.

How to send automated personalized emails from Google Sheets using Google Apps Script
A custom Google Apps Script mail merge workflow dispatching personalized HTML emails from spreadsheet data.

Whether you need to dispatch personalized event invitations, notify clients of account renewals, or send order confirmations, this google apps script email automation tutorial walks step-by-step through setting up your spreadsheet, formatting a responsive send html email google apps script template, dynamically replacing merge tokens, handling an automated email trigger on edit sheets, and managing your gmail quota google apps script limits.

Why Use Google Apps Script for Email Automation?

Many popular Google Sheets add-ons (like Yet Another Mail Merge or Mailmeteor) offer free tiers capped at 30 to 50 emails before forcing users into monthly subscriptions. Building your own mail merge google sheets free engine with Google Apps Script provides three massive advantages:

  • Zero Middleman Fees: You leverage Google’s native cloud backend for 100% free personalized communication.
  • Superior Inbox Deliverability: Because emails route directly through your authenticated Gmail/Google Workspace account, they carry your domain’s SPF, DKIM, and DMARC authentication, avoiding the spam promotions tab.
  • Unlimited Custom Logic: You can fetch dynamic numbers, attachment PDFs from Google Drive, or connect with our OpenAI API Google Sheets integration to generate custom personalized intro sentences for each recipient.

Understanding Daily Gmail Sending Quotas

Before launching outreach or notification sequences, know your account’s gmail quota google apps script threshold:

Google Account TypeDaily Email Recipient QuotaRate Limit / Burst Guidance
Free Personal Gmail (@gmail.com)100 recipients / 24 hoursIdeal for solopreneurs, clubs, and client invoicing
Google Workspace Paid (Business / Enterprise)1,500 recipients / 24 hoursEnterprise capacity for agencies, webinars, and operational alerts

Note: Quotas reset dynamically on a rolling 24-hour cycle. Sending emails in batches of 50 to 100 with short programmatic delays prevents temporary burst throttling.

Step 1: Setting Up Your Mail Merge Spreadsheet

Create a Google Sheet titled Email_Automation_Master. Across Row 1, set up the following 6 columns:

  • Col A (First_Name): Recipient personal name (e.g., Sarah).
  • Col B (Email_Address): Target inbox address.
  • Col C (Company_Name): Organization or account title.
  • Col D (Custom_Data): Dynamic variable (e.g., invoice link, webinar access URL, or renewal date).
  • Col E (Send_Status): Tracks state (e.g., Ready, Sent, Failed).
  • Col F (Timestamp_Sent): Automatic date-time stamp recorded when dispatched.

Step 2: Writing the Production Apps Script Code

Click Extensions > Apps Script. Replace existing text with this complete, production-ready script:

/**
 * Automated Mail Merge Script for Google Sheets
 * Dispatches personalized HTML emails and stamps send status.
 */
function sendPersonalizedEmails() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
  const data = sheet.getDataRange().getValues();
  
  // Track remaining quota
  const quotaRemaining = MailApp.getRemainingDailyQuota();
  Logger.log(`Remaining Gmail Quota: ${quotaRemaining}`);
  
  if (quotaRemaining <= 0) {
    SpreadsheetApp.getUi().alert("Daily email quota reached! Try again tomorrow.");
    return;
  }
  
  // Loop through rows (skipping Row 1 header)
  for (let i = 1; i < data.length; i++) {
    const row = data[i];
    const firstName = row[0];
    const email = row[1];
    const company = row[2];
    const customData = row[3];
    const status = row[4];
    
    // Process only rows marked 'Ready'
    if (status === "Ready" && email) {
      const subject = `Exclusive Strategy Briefing for ${company}`;
      
      const htmlBody = `
        <div style="font-family: Arial, sans-serif; max-width: 600px; color: #1e293b; line-height: 1.6;">
          <h2 style="color: #0f172a;">Hello ${firstName},</h2>
          <p>We have prepared your customized operational assessment for <strong>${company}</strong>.</p>
          <p>You can access your secure workspace materials and audit checklist using the personalized access link below:</p>
          <div style="margin: 25px 0;">
            <a href="${customData}" style="background-color: #2563eb; color: #ffffff; padding: 12px 24px; text-decoration: none; border-radius: 6px; font-weight: bold; display: inline-block;">Access Audit Dashboard ↗</a>
          </div>
          <p>If you have questions regarding this report, simply reply to this email.</p>
          <hr style="border: none; border-top: 1px solid #e2e8f0; margin: 30px 0;">
          <p style="font-size: 12px; color: #64748b;">Operations Excellence Team | BriskScale.co</p>
        </div>
      `;
      
      try {
        GmailApp.sendEmail(email, subject, "", {
          htmlBody: htmlBody,
          name: "Operations Team"
        });
        
        // Update Column E (Status) and Column F (Timestamp)
        sheet.getRange(i + 1, 5).setValue("Sent ✓");
        sheet.getRange(i + 1, 6).setValue(new Date());
        
        // Pause 500ms between sends to prevent Google API throttling
        Utilities.sleep(500);
      } catch (err) {
        sheet.getRange(i + 1, 5).setValue(`Error: ${err.message}`);
      }
    }
  }
}

Step 3: Creating Responsive HTML Email Templates

To ensure your emails render beautifully across Apple Mail, Outlook, and mobile devices:

  • Use Inline Styles: Email clients strip external <style> stylesheets. Always declare fonts, margins, and hex colors inline (e.g., style="font-family: Arial, sans-serif; color: #1e293b;").
  • Include a Styled CTA Button: A clean rounded button with generous padding (padding: 12px 24px) boosts click-through rates by up to 35% compared to raw hyperlinks.
  • Plain-Text Fallback: If an email client blocks HTML, Google’s GmailApp automatically provides basic text rendering based on your payload.

Step 4: Configuring Triggers: On-Edit vs Time-Driven

Depending on your business requirements, you can execute email dispatches through three methods:

  1. Manual Execution: Click Run in the Apps Script editor to send queued batches on demand.
  2. Time-Driven Triggers: In Apps Script, click Triggers (clock icon) > Add Trigger. Set event source to Time-driven > Day timer to send emails automatically every morning at 9:00 AM (perfect for our automated invoice reminder workflow).
  3. Instant On-Edit Triggers: Configure an onEdit(e) trigger so that when a team member marks a row dropdown as “Send Now”, the email fires immediately.

For more inspiration on eliminating manual administrative tasks, explore our comprehensive guide on business processes to automate.

Frequently Asked Questions

Will recipients see other people on the email?

No. The script iterates through your spreadsheet row by row and sends an individual, dedicated email to each person. No recipient sees any other contact’s name or address.

Can I send file attachments from Google Drive?

Yes. You can retrieve files using DriveApp.getFileById("YOUR_FILE_ID") and pass them into the options object: GmailApp.sendEmail(email, subject, "", { htmlBody: html, attachments: [file.getAs(MimeType.PDF)] }).

Can this replace Mailchimp or ConvertKit?

Google Apps Script is ideal for transactional notifications, client onboarding, invoice alerts, and targeted B2B outreach (under 1,500 emails/day). For massive promotional marketing blasts with unsubscribes and newsletter analytics, dedicated tools like Mailchimp remain best suited.

Related Posts

Leave a Reply

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