Google Apps Script - Sending Google Spreadsheet Row to Email
- by AME
Hi I am trying to write a script using Google Apps Script (Javascript) for a Google spreadsheet.
I am trying to do the same thing that is shown in this tutorial [http://www.google.com/google-d-s/scripts/sending_emails.html][1], but each row in my spreadsheet has 24 columns.
I would like to send out the contents of each row as an email. Here is the code as I am trying to use:
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getRange("A2:X31")
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var i = i + 1;
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = "Sending emails from a Spreadsheet";
MailApp.sendEmail(emailAddress, subject, message);
}
}?
The result is an email with the contents in the "B" column only. Can someone help me change this code to get all of the contents in each row (columns A-X).
Thanks,