我在另一个电子表格中使用了一个脚本,每当有人提交表单时,它都会向我发送电子邮件。它通过电子邮件向我发送一些重要问题的答案,以及用于查看电子表格上的完整回复的链接。
这是我的原始代码有效:
function Outreach_FormMailer(e) {
var recipient = "email@gmail.com";
var timestamp = e.values[0];
var name = e.values[1];
var subject = e.values[1]+" completed a Report for "+e.values[3]
var dates = e.values[7];
var goalMet = e.values[9]
var goalFocus = e.values[10]
var hyperlink = "myawesomelink.com"
htmlBody = name+' just completed the O/R Report for these dates: '+dates+'<br><br>Form completed on: '+timestamp+'<br>Was the goal met? '+goalMet+'<br>What was the goal focus? '+goalFocus+
'<br><br>View the Form:<a href="'+hyperlink+'">Click Here</a>';
MailApp.sendEmail(收件人,主题,htmlBody,{htmlBody:htmlBody});}
我想将此代码用于具有不同问题的新表单,因此我编辑了代码以仅对应于正确的问题。
这是不起作用的代码:
function Team_ApplicationMailer(e) {
var recipient = "email@gmail.com";
var timestamp = e.values[0];
var name = e.values[3];
var subject = e.values[1]+' filled out the Teams Application Form!' ;
var startdate = e.values[12];
var enddate = e.values[13]
var Focus = e.values[19]
var hyperlink="myawesomelink.com"
htmlBody = name+' from: '+e.values[1]+'just completed the Teams Application Form for these dates: '+startdate+' to '+enddate+'<br><br>Form completed on: '+timestamp+'<br><br>View the Form:<a href="'+hyperlink+'">Click Here</a>';
MailApp.sendEmail(recipient, subject, htmlBody, {htmlBody:htmlBody});
}
我已经完成了几封测试电子邮件,由于某种原因,这个版本的脚本将无法工作。我将此脚本添加到电子表格上已有响应的表单中。那会有什么不同吗?真的不确定我在将代码传输到不同的电子表格时做错了什么。