1

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.

  • 1
    Convert that sheet to a pdf and send it as an attachment or do the entire formatting in html. – Cooper Oct 22 '19 at 20:40
  • Possible duplicate of [Google Script - Send active sheet as PDF to email listed in cell](https://stackoverflow.com/questions/45781031/google-script-send-active-sheet-as-pdf-to-email-listed-in-cell) – Tedinoz Oct 25 '19 at 09:08
  • Would it be possible for you to share the sheet with dummy data along with the output format that you expect? I think the answer to this should be a lot similar to what I've provided here - https://stackoverflow.com/a/58047533/10713297 – Sourabh Choraria Oct 25 '19 at 16:14

0 Answers0