Created
April 17, 2016 11:42
-
-
Save pastcompute/69f69cd80e705d79fc363154552f110b to your computer and use it in GitHub Desktop.
Google sheets email merge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendEmails() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var startRow = 2; // First row of data to process | |
var numRows = 2; // Number of rows to process | |
// Fetch the range of cells A2:B3 | |
var dataRange = sheet.getRange(startRow, 1, numRows, 2) // r, c, NR, NC | |
// Fetch values for each row in the Range. | |
var data = dataRange.getValues(); | |
for (i in data) { | |
var row = data[i]; | |
var emailAddress = row[0]; // First column | |
var message = row[1]; // Second column | |
var subject = "Sending emails from a Spreadsheet"; | |
MailApp.sendEmail(emailAddress, subject, message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment