function onSubmit(e) {
var timestamp = e.values[0];
var question1 = e.values[1];
var address = "firstaddress@example.com, anotheraddress@example.com";
var subject = "Feedback form submitted";
var body = "Someone submitted the form at " + timestamp + " and said " + question1;
MailApp.sendEmail(address, subject, body);
}
This script will send an email to the address(es) in quotes after the var address = . The body of the email will contain the string that is in quotes after var body = , which includes the timestamp (from column A of the spreadsheet) and what the user submitted in the form (the contents of column B).
To get this to work for you, paste the above code into a new blank script that's associated with a form you've created, and then set up a trigger that runs the function onSubmit(e) when the form is submitted.
To set up the trigger, follow the instructions from this page:
- Open or a create a new form, then go to the results spreadsheet of that form.
- Click the Unsaved Spreadsheet dialog box and change the name.
- Choose Tools > Script Editor and write the function you want to run.
- Choose Resources > Current script's triggers. You see a panel with the message No triggers set up. Click here to add one now.
- Click the link.
- Under Run, select the function you want executed by the trigger.
- Under Events, select From Spreadsheet.
- From the next drop-down list, select On form submit.
- Click Save.
Of course if you have more than one question in your form, you'll need a variable for each of them (e.g. var question2 = e.values[2];) and you'll need to call those variables in the var body = statement.
Let me know if this works for you.