By Raj
Send Email from Google Sheets: Step-by-Step Apps Script Guide
Stop wasting hours manually copying and pasting data from your spreadsheet into Gmail. Whether you are sending invoice reminders, lead follow-ups, or team notifications, doing it one by one is a recipe for burnout and human error.
In this guide, I’m going to show you how to send automated emails from Google Sheets using a simple, "plug-and-play" Google Apps Script. Even if you have never written a line of code in your life, you can have this system running in under five minutes.
Why Use Apps Script for Email Automation?
Google Apps Script is a powerful, cloud-based scripting language that connects all Google Workspace applications. By using the GmailApp service, you can bridge the gap between your data and your inbox.
What You Can Do With This Script:
Send Bulk Emails: Reach hundreds of contacts with one click.
Personalize Content: Automatically insert names, dates, or custom links into each message.
Automated Notifications: Set triggers to send emails based on specific dates or form submissions.
Track Status: Automatically mark rows as "Sent" to avoid duplicate emails.
Step 1: Set Up Your Google Sheet
Before we touch the code, your data needs to be organized. The script needs to know exactly where to find the email addresses and names.
Create a new Google Sheet.
Set up your columns exactly like this:
- Column A: Recipient Email
- Column B: First Name
- Column C: Custom Message (Optional)
- Column D: Status (The script will write "SENT" here)
Expert Tip: Ensure there are no empty rows between your data entries, as the script is designed to process every row until it hits the end of your list.
Step 2: The "Copy-Paste" Google Apps Script Code
Now, let’s add the magic. Follow these steps to insert the apps script email automation code:
In your Google Sheet, go to Extensions > Apps Script.
Delete any code currently in the editor (like function myFunction() { ... }).
Copy and paste the entire block of code below:
JavaScript
/**
* Professional Google Sheets Email Automator
* Developed for: High-speed, personalized email sending
*/
function sendEmails() {
// 1. Setup - Access the active sheet
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const startRow = 2; // Skip the header row
const numRows = sheet.getLastRow() - 1; // Calculate how many rows have data
// 2. Fetch the data range (Columns A through D)
const dataRange = sheet.getRange(startRow, 1, numRows, 4);
const data = dataRange.getValues();
// 3. Loop through each row of data
data.forEach(function(row, index) {
const emailAddress = row[0]; // Column A
const firstName = row[1]; // Column B
const customText = row[2]; // Column C
const status = row[3]; // Column D
// 4. Check if the email has already been sent to avoid duplicates
if (status !== "SENT" && emailAddress !== "") {
// Define your Subject and Message Body
const subject = "Quick Update for " + firstName;
const message = "Hi " + firstName + ",\n\n" +
"I wanted to reach out regarding: " + customText + "\n\n" +
"Best regards,\nYour Automation Assistant";
try {
// 5. Use GmailApp to send the email
GmailApp.sendEmail(emailAddress, subject, message);
// 6. Update the Status column to "SENT"
sheet.getRange(startRow + index, 4).setValue("SENT");
// Pause briefly to ensure Google's servers stay happy
Utilities.sleep(100);
} catch (e) {
Logger.log("Error sending to: " + emailAddress + " - " + e.toString());
}
}
});
}Step 3: Authorize and Run Your Script
After pasting the code, click the Save icon (floppy disk) and name your project "Email Automator."
Running the Script:
Click the Run button at the top of the editor.
Authorization Required: A popup will appear. Click Review Permissions.
Select your Google Account.
You might see a warning saying "Google hasn't verified this app" (since you just wrote it!). Click Advanced > Go to Email Automator (unsafe).
Click Allow.
Once authorized, the script will execute. Switch back to your Google Sheet—you should see the "Status" column filling up with "SENT" in real-time!
How to Automate Your Emails (Triggers)
Manually clicking "Run" is fine, but apps script email automation shines when it's hands-free.
Add a "Send" Button
Make it user-friendly for your team:
Go to Insert > Drawing.
Draw a text box or shape, type "SEND EMAILS," and click Save and Close.
Right-click the image in your sheet, click the three dots (⋮), and select Assign Script.
Type sendEmails and click OK. Now, clicking the button runs the script!
Set a Time-Based Trigger
Want to send emails every Monday at 9 AM?
In the Apps Script editor, click the Triggers icon (the clock) on the left sidebar.
Click + Add Trigger.
Choose sendEmails as the function, and set the event source to Time-driven.
Troubleshooting Common Errors
- "Limit Exceeded": Google has daily quotas. Free Gmail accounts can send to 100 recipients per day; Google Workspace accounts can send to 1,500–2,000.
- Authorization Error: If you add new features (like Google Drive access), you must re-authorize the script.
- Script Not Running: Ensure your column indices in the code match your sheet. In coding, the first column is 0, the second is 1, and so on.
Advanced Improvements
Once you’ve mastered the gmailapp sendemail example, try these upgrades:
- HTML Emails: Use GmailApp.sendEmail(email, subject, "", {htmlBody: htmlText}) to send branded, designed emails.
- Attachments: Pull a PDF from Google Drive and attach it automatically to each message.
- Conditional Sending: Add a column for "Send Date" and only trigger the email if today's date matches that column.
Conclusion
You now have a fully functional system to send bulk emails from Google Sheets script. This simple automation eliminates the drudgery of manual data entry and ensures your communication is consistent and professional.
Ready to take your business automation to the next level?
If you need a custom script for complex workflows, CRM integrations, or advanced reporting, I’m here to help. [Contact me here for custom Google Workspace automation services.]
Frequently Asked Questions (FAQs)
Can I send attachments using this Google Sheets script?
Yes. You can use DriveApp.getFileById() to grab a file and include it in the attachments parameter of the sendEmail function.
Is there a limit to how many emails I can send?
Yes, Google imposes daily quotas. Personal @gmail.com accounts are typically limited to 100 recipients per day, while paid Workspace accounts allow up to 2,000.
Does the script work if the spreadsheet is closed?
If you set up a Time-based Trigger, the script will run automatically in the cloud even if your computer is turned off and the spreadsheet is closed.