3

I need help with the google form. The problem is this: I want to receive an email with its results for every user who completes the form. For example, if you had a form that required email, name and surname. I would like to receive an email like this: " New registered user mail: [email protected] name: jon surname: kess "

I tried addons, but they either didn't work or were limited to a few emails. Thank you all

2
  • How many users will complete the form? Commented May 15, 2019 at 13:49
  • Welcome to webapps. If you want some clarifications about an answer please post a comment under it. As per site guidelines if an answer addressed your question, you should accept it so others can benefit as well -. (Why vote?) Commented May 15, 2019 at 14:09

2 Answers 2

3

You can do that with a simple script.

To write the script you should use the Script Editor on the answers spreadsheet linked to the form (not the script editor in the form).

  • Go to Tools -> Script editor...
  • When in the script editor, erase all the presented code and replace it with the following:

The code:

// Auto-Confirmation Email to "[email protected]"

   function AutoConfirmation(e){
      var theirFirst = e.values[2];
      var theirLast = e.values[3];
      var theirEmail = e.values[4];
      var myEmail = "[email protected]";
      var theWhat = e.values[1];
      var subject = "New Form Submitted";
      var message = "New registered user mail: " + theirEmail + " name: " + theirFirst + " surname: " + theirLast + " has filled the form: " + theWhat; 

   MailApp.sendEmail (myEmail, subject, message);
   }
  • Save
  • Authorize
  • Now click on the clock icon on the toolbar and on the new page, set up a trigger for On form submit and save the trigger.

trigger

  • Test and Enjoy!

Notes

The e.values 1, 2, and so on, correspond to the columns on the spreadsheet where the answers are submitted. Keep in mind that the numbering for the columns start with 0. (Zero being the column reserved for the timestamp.)

*You can read all about limitations on Google accounts and triggers at: Quotas for Google Services and Simple Triggers

EDIT (following OP request)

How I can do bold in the var message?

I am afraid you will complicate things. I would stick to just changing lines using the accepted \n. Please have a look at the updated code:

function AutoConfirmation(e){
   var theirFirst = e.values[2];
   var theirLast = e.values[3];
   var theirEmail = e.values[4];
   var myEmail = "[email protected]";
   var theWhat = e.values[1];
   var subject = "New Form Submitted";
   var message = "New registered user: \n\n EMAIL: " + theirEmail + " \n FIRST name: " + theirFirst + " \n LAST name: " + theirLast + " \n\n Filled form: " + theWhat; 

MailApp.sendEmail (myEmail, subject, message);
}

PS: Please try following the site rules as explained here and when in need of clarifications just add a comment, not an answer (as you just did).

0
0

If you want to be simply notified when a form has been submitted, you can subscribe to changes on the responses sheet.

If you want something like a complete digest of each submission, you'll need to use Google Apps Script to take the submitted data from a Google Form, use the trigger onFormSubmit and email it to you. Example:

function myFunction(e) {
  var formData   = e.values;
  var field_1  = formData[0];
  var field_2 = formData[1];
  MailApp.sendEmail({
     to: "your_email_address",
     subject: "Testing trigger",
     htmlBody: field_1 + ": " + field_2
   });
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.