我们已经解决了应用程序脚本最后一个功能上的所有错误。该脚本将向客人预订发送电子邮件提醒。
代码特别在mailapp
函数中断(第27行)。任何输入将不胜感激!
function sendEmail() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
Logger.log(ss.getName());
var sheet = ss.getActiveSheet()[0];
var startRow = 1;
// First row of data to process
var numRows = 11;
// Number of rows to process
var dataRange = ss.getActiveSheet().getRange(startRow, 12, numRows, 11);
//Assigning spreadsheet feilds
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var firstName = row[1];
var guestFirstN = row[6];
var guestLastN = row[7];
var arrivalDate = row[8];
var numberNights = row[9];
var rmName = row[10];
var recipient = row[11];
//email data
var subject = "IMPORTANT: Your Roommate Has Requested An Overnight Guest!";
var message = "Your roommate" + firstName + "has requested that" + guestFirstN + "stay as a guest in your residence room on" + arrivalDate + "for" + numberNights + "." + "<br> If you do not agree to have" + guestFirstN + "stay in your residence room please contact the front desk as soon as possible. <br> Not contacting the front desk with adequate notice will give implied consent to the guest staying.";
MailApp.sendEmail({
to: recipient,
subject: subject,
message: message,
});
}
}
答案 0 :(得分:2)
您是否尝试使用MailApp类:
// MailApp.sendEmail(to, replyTo, subject, body)
MailApp.sendEmail("recipient@example.com",
"replies@example.com",
"TPS report status",
"What is the status of those TPS reports?");
或在代码中使用message
更改body
https://developers.google.com/apps-script/reference/mail/mail-app