Does anyone know how to customize the format of an email body in a script or within the cell formula when sending an email from google sheets?
The first attachment is the incorrect email body the script is sending.
And the second attachment is the correct email body format I need the script to send.
Code below:
// has been sent successfully.var EMAIL_SENT = 'EMAIL_SENT';/** * Sends non-duplicate emails with data from the current spreadsheet. */function sendEmails2() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 2; // First row of data to process var numRows = 1000; // Number of rows to process // Fetch the range of cells A2:D1000 var dataRange = sheet.getRange(startRow, 1, numRows, 1000); // 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 = row[0]; // First column var subject = row[3]; // Second column var message = row[3]; // Third column var emailSent = row[3]; // Fourth column if (emailSent !== EMAIL_SENT) { // Prevents sending duplicates MailApp.sendEmail(emailAddress, subject, message); sheet.getRange(startRow + i, 4).setValue(EMAIL_SENT); // Make sure the cell is updated right away in case the script is interrupted SpreadsheetApp.flush(); } }}