【发布时间】:2019-10-18 21:45:14
【问题描述】:
我的Google Apps Script 从HTML form 接收数据,然后向客户发送电子邮件确认。它从input type=email 获取电子邮件地址,如果此输入字段留空,则脚本会产生错误。
这是我Google Apps Script的相关部分:
function doPost(e) {
var email = e.parameter.Email;
MailApp.sendEmail({
to: email,
subject: "Submission Received",
body: "We have received your submission. Thank you.",
htmlBody: HtmlService.createHtmlOutputFromFile(
"Confirmation"
).getContent()
});
}
我该如何解决这个问题,以便当我引用的 form input 字段为空时,我的脚本不会产生错误?
(我知道解决此问题的一种方法是将required 属性放在input 上,但该字段是可选的,因此无法解决我的问题。)
【问题讨论】:
标签: javascript google-apps-script web-applications