I have created a form that asks the user for their name and campus mailbox number. I want to email these responses to another user when the form get submitted.
I am using this code and I don't get any emails with with responses to the form. This script is written in the google sheets that was created/linked to the form where the answers go.
I also made sure in the script editor to turn the on form submit trigger on under Edit>Current Project Triggers.
function onFormSubmit(e){
var name = e.values[1];
var mailbox = e.values[2];
var subject = "New Cold Pack Order";
var message = "New Cold Pack Order received for " + name + " to be delivered to Mailbox number " + mailbox; //email message to be sent.
MailApp.sendEmail ("myemail@gmail.com", subject, message);
}
When I go debug the code I get this error:
TypeError: Cannot read property "values" from undefined. (line 2, file "Code")
When I hard code results and submit the form I don't get an email sent to me. WHen I hard code the script and test it in the script editor it works.
I am looking for ideas on what I need to do to get this to run or what I need to do to get this function to work properly.
Thank you!