I am trying to send emails to employees by using gs to pull the info from a sheet. I figured out how to pull the email address, message and subject, however, I want to include information from multiple columns in the message. Below is what I have so far....however I also want to include information from additional columns in the email message. For example, row[1] contains a message, row[3], row[4], row [5] contain values for Hotel 1, Hotel 2, Hotel 3 which i want to include in the message body.
/**
* Sends emails with data from the current spreadsheet.
*/
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:D3
var dataRange = sheet.getRange(startRow, 1, numRows, 4);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = 'Your hotel reservation options';
MailApp.sendEmail(emailAddress, subject, message);
}
}