This template helps automate email sending from Google Sheets using Gmail and Google Apps
Script. Perfect for sending reports, invoices, or reminders with minimal effort. Follow these steps
to set up:
Steps:
1. Prepare Google Sheets
○
Create a Google Sheet with these columns:
■ Name: Recipient's name
■ Email: Recipient's email address
■ Message: Content of the email
■ Status: Tracks whether the email is sent
2. Open Apps Script
○
In the Google Sheet, click Extensions > Apps Script.
○
Add the Code
Copy and paste this code into the Apps Script editor:
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var startRow = 2; // Skip header row
var numRows = sheet.getLastRow() - 1; // Get rows with data
var data = sheet.getRange(startRow, 1, numRows, 4).getValues(); // Get
values
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[1]; // Email column
var message = row[2]; // Message column
var subject = "Automated Email from Google Sheets";
if (row[3] !== "Sent") { // Check if email is already sent
GmailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 4).setValue("Sent"); // Mark as sent
}
}
}
3. Set up a Trigger
○
Go to Apps Script > Triggers.
○
Add a trigger for the sendEmails function.
○
Set it as a time-driven event (e.g., run daily).
4. Test the Script
○
○
Enter sample data in Google Sheets and run the script to send emails.
Check the "Status" column to see if emails were sent successfully.