As you can see I am using this code to send an email to whoever submit the form.
However, I do get the error that var emailTo = e.namedValues[2].toString();
has the error of
"TypeError: Cannot read property 'namedValues' of undefined (line 5, file "Code")"
function sendEmail(e) {
var html = HtmlService.createTemplateFromFile("htmlemail.html")
var htmlText = html.evaluate().getContent();
var emailTo = e.namedValues[2].toString(); //column B is for the email
var subject = "Thanks for participation";
var textBody = "This email requires HTML support. Please make sure you open with a client that supports it."
var options = { htmlBody : htmlText };
if (emailTo!== undefined){
GmailApp.sendEmail(emailTo, subject, textBody, options)
}
}
Please help. Note that column B in the spread sheet is where the email should be filled.