问题
How do I send a notification email after a form has been submitted?
I have a Google Form, I open it and I go to menu More->Script Editor and add a script:
function OnSubmit(e) {
MailApp.sendEmail ("myemail@mydomain.com", "Form Submited: Foo feedback " + Date.now(), "Form Submited: Foo feedback");
}
I save the script and test it works by pressing the run button. The email gets delivered to myemail@mydomain.com.
Then I fill in the Google Form, but the email does not arrive in myemail@mydomain.com mailbox.
P.S. I do not want to use "Email Notifications for Forms" plugin because it requests access to to many privileges. I do not want to use "Form Notifications" because for some reason it does not work for me (the emails do not get delivered).
回答1:
Finally found it, well hidden under
- Edit form mode
Responses
tab...
menu buttonGet email notifications for new responses
.
回答2:
To send an email on submit you need to save this script, test it in the script editor (and accept when you see the permissions popup), and then submit a form.
The script looks for submit triggers, if it finds none it adds a new one that sends the email.
function respondToFormSubmit() {
MailApp.sendEmail ("email@domain.com", "Form Submited: Foo feedback " + Date.now(), "Form Submited: Foo feedback");
}
var form = FormApp.getActiveForm();
var triggers = ScriptApp.getUserTriggers(form);
var existingTrigger = null;
for (var i = 0; i < triggers.length; i++) {
if (triggers[i].getEventType() == ScriptApp.EventType.ON_FORM_SUBMIT) {
existingTrigger = triggers[i];
break;
}
}
if (!existingTrigger) {
var form = FormApp.getActiveForm();
var trigger = ScriptApp.newTrigger('respondToFormSubmit')
.forForm(form)
.onFormSubmit()
.create();
}
回答3:
The easier way, now, is to use the "Notification rules..." item under "Tools".
来源:https://stackoverflow.com/questions/49336040/how-do-i-send-an-email-when-a-google-form-is-submitted