0
function onSubmit(e) {
var myemail = "[email protected]" // please, replace myemail by your email
try{
var formResponse = e.response;//get the form response
var editResponseUrl = formResponse.getEditResponseUrl(); //get the individual form url just in case the respondent needs to edit its anwers later
var itemResponses = formResponse.getItemResponses();// get all item questions and anwers
var itemResponse
var title
var response
for (var i = 0; i < itemResponses.length; i++) { // iterate for all form items
itemResponse = itemResponses[i];
title = itemResponse.getItem().getTitle().toUpperCase(); // get the question title. In our form can be EMAIL or NAME
response = itemResponse.getResponse().toString(); // get the corresponding answer
if(title.indexOf("EMAIL", 0) != -1){ // if the title is "EMAIL"
var email = response.toLowerCase(); // get it
}
else if (title.indexOf("NAME", 0) != -1){ // if the title is "NAME"
var name = response.toLowerCase(); // get it
}
}
var subject ="Confirmation"; // subject of the message you're assembling
var message = "Dear " + name + ",\n\n"; // body of the message you're assembling
message += "Thanks for answering our survey. \n\n"; // body of the message you're assembling
message += "Click on the link bellow to edit your previous answers:\n\n"; // body of the message you're assembling
message += editResponseUrl + "\n\n"; // body of the message you're assembling
MailApp.sendEmail(email, subject, message, {replyTo:myemail,cc:myemail}); // send the message
}
catch(e) { // if something wrong happens
MailApp.sendEmail(myemail, "Error in Auto replying to contact form submission.", e.message); // tell me
}
}
什么类型的问题?你有错误信息吗?不要获取网址?不要发送邮件? – wchiquito
我什么也没得到,但一个应用程序脚本错误无法调用未定义的方法“getEditResponseUrl” – INOH
请记住,您不能从代码编辑器(简单的方法)测试此方法,所以您必须填写表单并发送它触发器已被激活。 – wchiquito