我制作了一个包含许多字段的谷歌表单。我已经放置了一个触发器来将表单值发送到一个特定的(也将它保存在谷歌驱动器的 excel 表中)。但它也会将用户未选择的空白值邮寄给我。我应该如何通过修改以下代码仅将填充的值发送到邮件。
function Initialize() {
var triggers = ScriptApp.getScriptTriggers();
for(var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
ScriptApp.newTrigger("SendGoogleForm")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onFormSubmit()
.create();
}
function SendGoogleForm(e)
{
try
{
var email ="abc@abc.com";
var subject = "Form Submission";
var s = SpreadsheetApp.getActiveSheet();
var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var message = "";
for(var i in headers) {
message += headers[i] + ' :: '+ e.namedValues[headers[i]].toString() + "\n\n";
}
message += "Sheet URL :: " + SpreadsheetApp.getActiveSpreadsheet().getUrl() + "\n";
MailApp.sendEmail(email, subject, message);
} catch (e) {
Logger.log(e.toString());
}
}
请帮我怎么做。谢谢 :)