gpt4 book ai didi

javascript - 使用 MailApp.sendEmail 时发生服务器错误

转载 作者:行者123 更新时间:2023-12-02 15:29:07 25 4
gpt4 key购买 nike

我们已经解决了应用程序脚本最后一个函数中的所有错误,一直到此服务器错误。该脚本用于向客人预订发送电子邮件提醒。

该代码特别破坏了 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,
});
}
}

最佳答案

您是否尝试使用 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?");

或在代码中使用body更改message
https://developers.google.com/apps-script/reference/mail/mail-app

关于javascript - 使用 MailApp.sendEmail 时发生服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33479699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com