I'm working on this template to send an email to the person that fill a form, the problem is that everytime I try to run it I get this error
TypeError: Cannot read property "values" from undefined. (line 4, file "Code")
Can someone help me out figuring out what the problem is?
function emailOnFormSubmit(e) {
// Create as many variables as answers (columns in your spreadsheet) you require to send
var Timestamp = e.values[0];
var mail = e.values[1];
var name = e.values[2];
var Break = e.values[3];
// The subject of the email
var subject = "Break time! " + name;
// emailBody is for those devices that can't render HTML, is plain text
var emailBody = "Hola " + name + "tu hora de salida es " + Timestamp + "tu hora de regreso es " + Timestamp + time (0,20,0) +
"\nFrom " + city +
"\nWith email " + mail +
"\nRegister on " + timestamp +
"\n\nThank you for register!";
// html is for those devices that can render HTML
// nowadays almost all devices can render HTML
var htmlBody = "Thank you, your form was submitted on <i>" + timestamp + "</i>" +
"<br/><br/>The details you entered were as follows: " +
"<br/>Your Name: <font color=\"red\"><strong>" + name + "</strong></font>" +
"<br/>From: " + city +
"<br/>With email: " + mail;
// More info for Advanced Options Parameters
// https://developers.google.com/apps-script/reference/mail/mail-app#sendEmail(String,String,String,Object)
var advancedOpts = { name: "No reply", htmlBody: htmlBody };
// This instruction sends the email
MailApp.sendEmail(mail, subject, emailBody, advancedOpts);
}