Google脚本发送电子邮件失败:没有收件人,但电子邮件已到达 [英] Google scripts "Failed to send email: no recipient" but email arrives
本文介绍了Google脚本发送电子邮件失败:没有收件人,但电子邮件已到达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行以下代码时出现错误:
发送电子邮件失败:没有收件人
代码嵌入到链接到Google表单的Google电子表格项目中。
即使电子邮件变量的值是正确的,MailApp.sendEmail(email, subject, body, {htmlBody: body, attachments: pdf});
调用时也会出现错误。此外,收件人收到电子邮件,但随后代码不再继续。
代码提供如下:
// When Form Gets submitted
function onFormSubmit(e) {
//Get information from form and set as variables
var cognome = e.values[1].toUpperCase();
var nome = e.values[2].toUpperCase();
....
var email = e.values[9].toString();
// Prepare a pdf document. Save and close the temporary document
copyDoc.saveAndClose();
// Convert temporary document to PDF
var pdf = DriveApp.getFileById(copyId).getAs("application/pdf");
// Attach PDF and send the email
var subject = "Subject";
var body = '....';
Logger.log(email);
MailApp.sendEmail(email, subject, body, {htmlBody: body, attachments: pdf});
// Delete temp file
DriveApp.getFileById(copyId).setTrashed(true);
}
推荐答案
问题是在最后一封电子邮件后没有更多的空单元格,这会生成空条目,您将收到警告。
删除空行可能会解决此问题。
这篇关于Google脚本发送电子邮件失败:没有收件人,但电子邮件已到达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文