I am getting this error when I try to run a basic script in Google Sheet's script editor:
TypeError: Cannot read property "namedValues" from undefined. (line 5, file "Code")Dismiss
Script:
function autoResponder(e){
var user = {name: e.namedValues['Name'][0], email: e.namedValues['Email'][0]};
var html =
'<body>' +
'<h2> Test </h2><br />' +
'<p> Greetings Earthling </p>' +
'</body>'
MailApp.sendEmail(
email, // recipient
'test GmailApp', // subject
'test', { // body
htmlBody: html // advanced options
}
);
}
This is the complete code. I used following link to get auto emails when someone submits a new form. https://codingislove.com/auto-responding-google-form-2-lines-code/#comment-50377 Then I tried to change it to HTML email. Please let me know if you have any questions.
Do you have any idea why this may be happening? Many thanks in advance!
You are not passing any value when you call autoResponder()
.
Unless you show us that part of your code, we can only guess why. @Ashish suggested putting console.log(e)
as the first line inside your function, but we already know what that will show: undefined
so you need to trace back a little earlier in your code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.