function sendSelectedEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var activeRange = sheet.getActiveRange();
var data = activeRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[0];
var subject = row[1];
var message = row[2];
MailApp.sendEmail(emailAddress, subject, message);
}
}
htmlBody
нужный HTML контент письма.MailApp.sendEmail(emailAddress, subject, message, {
htmlBody: '<h1>Привет, Хабр!</h1>',
});
function dataToHtmlTable_(data){
return JSON.stringify(data, null, " ")
.replace(/^\[/g, "<table border rules=all>")
.replace(/\]$/g, "</table>")
.replace(/^\s\s\[$/mg, "<tr>")
.replace(/^\s\s\],{0,1}$/mg, "</tr>")
.replace(/^\s{4}"{0,1}(.*?)"{0,1},{0,1}$/mg, "<td>$1</td>"); //bgcolor=" + data.getBackground + "
}
message.htmlBody = dataToHtmlTable_(data) + "<br><br>Автор письма";
MailApp.sendEmail(message);