我当前的脚本能够发送电子邮件,但是它发送多封电子邮件,每封电子邮件中都有一行数据。我希望脚本能够发送一封包含所有数据行的电子邮件。
function tazEmail() {
var sheet = SpreadsheetApp.openById("1naSWINA8_uxeLUsj0lFntqILyDj2nirb56uvkBel79Y").getSheetByName("Sheet3");
//var ss = SpreadsheetApp.getActive().getSheetByName("CRM Feedback");
var data = sheet.getRange(2, 1, sheet.getLastRow(), sheet.getLastColumn()).getValues();
var manager_email = "email@email.org.au";
for( var i = 1; i< data.length;i++ ) {
var timestamp = data[i][0];
var requesterEmail = data[i][1];
var starRating = data[i][2];
var requestCatergory = data[i][3];
var description = data[i][4];
var label = data[i][5];
var ticketId = data[i][6];
var comment = data[i][7];
var status = data[i][8];
var priority = data[i][9];
var office = data[i][10];
var message = "";
var check = data[i][11];
if (check == "complete"){
continue;
}else {
var subject = "CT IT feedback - ";
var body = "<body>";
message +=
"<p><b>Timestamp by: </b>" + data[i][0] + "</p>" +
"<p><b>Requester Email: </b>" + data[i][1] + "</p>" +
"<p><b>Star Rating: </b>" + data[i][2] + "</p>" +
"<p><b>Request Category: </b>" + data[i][3] + "</p>" +
"<p><b>Description: </b>" + data[i][4] + "</p>" +
"<p><b>Label: </b>" + data[i][5] + "</p>" +
"<p><b>Ticket ID: </b>" + data[i][6] + "</p>" +
"<p><b>Comment: </b>" + data[i][7] + "</p>" +
"<p><b>Status: </b>" + data[i][8] + "</p><br><br>";
MailApp.sendEmail({
to: manager_email,
subject: subject,
htmlBody: message,
});
}
}
}
答案 0 :(得分:2)
尝试:
ser