How To Send Email Based On Cell Value in Google Sheets

In this tutorial, you will learn how to send an email based on cell values in Google Sheets.

How To Send Email Based On Cell Value in Google Sheets

Do you ever find yourself needing to automatically send emails from your Google Sheets? Maybe you have a spreadsheet that keeps track of customer emails, and you need to send out an email to the customer when the order is on the way.

Luckily, Google Sheets makes it possible to do this with a few lines of code using Apps Script. In this guide, we will show you how to use Apps Script to send an email based on a cell value in Google Sheets. This can save you a lot of time, and help automate your workflow.

How to Send an Email Using Data from a Spreadsheet in Google Sheets

Here’s how to send an email using data from a spreadsheet in Google Sheets.

Step 1

First, open up the spreadsheet that includes the email data.

Step 2

Next, select the option Extensions > Apps Script to open up the Apps Script editor in a new tab.

Step 3

Select the file in the Apps Script editor and type the code seen below:

function sendEmail() {

var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Sheet1”).getRange(“B2”);

var emailAddress = emailRange.getValue();


The code above defines a function called sendEmail() that retrieves the string in cell B2 of the current project. The string is stored in the emailAddress variable.

Step 4

Next, we’ll create placeholder variables for the message and subject of the email using the following lines of code:

var message = ‘This is a sample message’;

var subject = ‘Email Alert from Google Sheets’;

Step 5

The last line of the sendEmail() function is what is responsible for actually sending the email. The MailApp.sendEmail() function is a built-in method that sends an email to a specified recipient using the current user’s email address.

MailApp.sendEmail(emailAddress, subject, message);

Step 6

After typing the whole function, click on the Save icon found in the toolbar.

Step 7

Click on the Run option to execute the sendEmail function.

Step 8

The execution log should indicate that the function has completed its execution.

Step 9

The recipient should now be able to see an email similar to the one shown below.


This guide should be everything you need to send an email based on cell value in Google Sheets.

You may make a copy of this example spreadsheet to test it out on your own.