The script below from the simple form below always generates the following error;
TypeError: Cannot read property "values" from undefined. (line 2, file "Code")
Form Response Sheet:
Script:
function onFormSubmit(e) {
var timestamp = e.values[0];
var email = e.values[1];
var name = e.values[2];
var template = HtmlService.createTemplateFromFile("ProfileEmail");
template.name = name;
template.email = email;
MailApp.sendEmail(email,
"Thank you for your time!",
"",
{ htmlBody: template.evaluate().getContent() });
}
In the new version of forms and sheets, you can also use named values, example.
The value following "namedValues" needs to be the same as the column header your looking for.
You can always add "Logger.log(e)" just above timestamp there and get what ever values are passed to the script, to see if your even receiving what your looking for.
With out seeing the rest of code the html part, not exactly sure where issue is.
If you're testing your trigger function in the debugger,
e
will be undefined.See How can I test a trigger function in GAS?.