Making Google Docs Forms send useful email notifications

Forms created in Google Docs can serve as Contact Forms on your web site. You can enable notifications to receive an email when the form is submitted. However, by default the email just tells you that the form was submitted without providing any of the content. Often it would be more useful if the email provided the values submitted in the form. Especially if you are receiving the email on a mobile device where Google Docs is not that easy to navigate.

Making a Google Form send the content of the form is actually quite straightforward. These are the steps that we will follow

  1. Add an onFormSubmit script that sends the form values in an email
  2. Add an On Form Submit trigger to run this function
  3. Disable the default notification email
  4. Test

The following example assumes you've created a form with just two fields. The first field for an email address, and the second field for a name.


Create onFormSubmit function

Open the spreadsheet associated with the form. Click Tools > Script Editor. Paste in the following function


function onFormSubmit(e) {
  var email = e.values[0];
  var name = e.values[1];


  // change this address to be the address where you want the notification to go  
  var to = "xxxxxx@xxxxxx.com";
  var subject = "Form Notification";
  var message = "Full Name: " + name + "\n";
  message += "Email Address: " + email + "\n";
  
  MailApp.sendEmail(to, subject, message);
}

Add On Form Submit trigger


To make this run, you need to define a trigger. From the Script Editor click Triggers > Current script's trigger's. Add a new trigger to execute onFormSubmit, From Spreadsheet, On Form Submit. Save this and authorize the function when prompted.

Disable Default Notification

From the Google Spreadsheet click Tools > Notification Rules. Uncheck the box for notifying you when a user submits the form. While you are testing you may want to leave this box checked, just to make sure you don't miss any notifications.

Test

Now enter some sample data in your form and submit. Check that the email comes through as you expected, and adjust the function to alter the subject or message as you desire.

The above approach will let you receive notification emails when your Google Forms are submitted. The notification emails will contain the actual content submitted in the form.