0

I'm trying to trigger an email to send all data on a sheet in columns B:F. I've found this tutorial quite helpful but can't quite get my head round it.

/**
 * Sends emails with data from the current spreadsheet.
 */
function email() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");

  var startRow = 1; // 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, 2, numRows, 6);
  // Fetch values for each row in the Range.
  var data = dataRange.getValues();
  for (i in data) {
    var row = data[i];
    var emailAddress = "abc@cba.com"; // First column
    var message = row[1]; // Second column
    var subject = 'Jobs in Next 5 Days';
    MailApp.sendEmail(emailAddress, subject, message);
  }
}

What would I need to change that in order to send all non-blank data in B:F on Sheets in one email but keeping the tabular spreadsheet format?

0

You could send emails using plain text, HTML or both.

  • If you decide to use plain text, then you could use a tab character by using \t as the column separator.
  • If you decide to use HTML, then you could use the table tags like

    <table>
      <tr>
        <th>Columna A</th>
        <th>Column B</th>
      </tr>
      <tr>
        <td>Value A</td>
        <td>Value B</td>
      </tr>
    </table>
    

Be aware that the body (plain text) an htmlBody (HTML) arguments should be strings

For further details checkout:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.