I have a document that automatically fills in everyone on call for my company for the day. I would like to be able to trigger this to send the data from the sheet as an email everyday and keep all of the current formatting.
I have created a function that does send the email. This function currently sends 65 separate emails with the data (one for each line of data in the sett) and it is one large clump of unreadable data.
function dailyEmail (){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Roster");
var dataRange = sheet.getRange("A1:C65");
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0 ; i<data.length ; i++) {
var row = data[i];
var emailAddress = "my@email.com" ; // First column
var message = data; // Second column
var subject = 'Daily Roster';
MailApp.sendEmail( emailAddress , subject, data);
}
}
I would like to be able to trigger this to send the data from the sheet as an email everyday and keep all of the current formatting. I know how to set up the trigger to auto email , I just need to fix the code to email the data correctly.