异常:发送电子邮件失败:没有收件人



我创建了一个发送电子邮件的脚本。每次我在formCodes上运行它时,脚本都会起作用。另一方面,在分配了这个脚本之后,我得到了这个错误:

异常:发送电子邮件失败:没有收件人

function sendTicket() {

var ss = SpreadsheetApp.getActiveSpreadsheet();
var ms = ss.getActiveSheet();
var recipient = ms.getRange(1,1).getValue();/**will get the specific email address */
var message = {/**contents of the email */
to: recipient,
subject: "Ticket",
body: "Hi,nnPlease see attached ticket.nnThank you!",
name: "John",
attachments: [SpreadsheetApp.getActiveSpreadsheet().getAs(MimeType.PDF).setName("Ticket Transaction")]
}
MailApp.sendEmail(message);
}
function sendTicket() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ms = ss.getActiveSheet();
var recipient = ms.getRange(1,1).getValue();/**will get the specific email address */
var message = {/**contents of the email */
to: recipient,
subject: "Ticket",
body: "Hi,nnPlease see attached ticket.nnThank you!",
name: "John",
attachments: [SpreadsheetApp.getActiveSpreadsheet().getAs(MimeType.PDF).setName("Ticket Transaction")]
}
if(recipient.length>0) {
MailApp.sendEmail(message);
} else {
SpreadsheetApp.getUi().alert(`Recipient: ${recipient}`);
}
}

最新更新