ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Internet & the Web

How To Get Google Docs Contact Form Data in Email Message Content

Updated on July 13, 2014
Sending automated email on submit of Google Docs Contact Form with content of form submitted.
Sending automated email on submit of Google Docs Contact Form with content of form submitted. | Source

One of the Most Popular Free Contact Forms on Web

Google Docs is certainly one of the most popular contact form used on the web. This has been used by many companies since it provides a free contact form interface and the responses are recorded in a Google Spreadsheet format, which is very easy to manage and take action on.

Though there are several other free contact forms available on the web, however people prefer to rely on Google instead of some unknown company.

In case you don't know about creating contact form using Google Docs you can checkout below resources.

Youtube Video: How To Create Contact Form on Google Docs

Steps and Code to Setup Email

Below are the simple steps to configure your existing Google Docs form with a email trigger with content.

Step 1: Create Script

In this step we are going to create a Java Function which can do the magic of auto email with content on form submission.

On your Contact for Go to Tools –> Script Editor and copy-paste the below displayed code in code editor.

Make sure you replace the value of variable “email” with your own email address.

Google Docs Script to Send Email Content On Form Submission

function sendEmailWithFormContent(e)
  // replace with your own email address 
  var email = ""; 
  // Optional but change the following variable
  // to have a custom subject for Google Docs emails
  var subject = "Contact Form Submitted";  

  var message = "";
  for(var field in e.namedValues) {
    message += field + ': ' + e.namedValues[field].toString() + "\n";
  // This is the MailApp service of Google Apps Java Util
  // which is used to send emails. 
  MailApp.sendEmail(email, subject, message);  

Step 2: Create Trigger to Run the Java Function

The Java Function we have created needs to be bind with an event on contact form. This can be done using below steps.

Navigate to Triggers –> Current Script’s Triggers and associate the sendEmailWithFormContent function with “On Form Submit” event.

Step 3: Authorize the script to be run

The google apps requires you to authorize the script to be run on a event. If you do not authorize this script the Java function is not going to be executed. To do this you just need to authorize the google docs account for which you have created the form.


The Google Docs can be used for doing a lot of useful business documentation and with the power of Google Apps it can make you really productive.

The Above Java function can be easily customized to do a lot of fancy things on contact form submission, for example

- Sending Automated Reply to contact form

- Sending multiple emails to your different employees/account holders.

Hope you found this hub page useful for you business. Let us know your thoughts about this in comments section.


    0 of 8192 characters used
    Post Comment

    • profile image

      Rose 3 years ago


      e.namedValues is not working for me either...has Google just changed something? I really want to get this to work!

    • profile image

      Vijay 3 years ago

      for(var field in e.namedValues) {

      It is showing error for me. Any one help me

    • profile image

      need help 4 years ago

      excellent script. But please help me further

      i have created "EMAIL" column in the form.....

      After entering the data....the email should be sent to the specific person in the email address in the column "email".

      Please help me to set this in simple way

    • profile image

      Brian 4 years ago

      Yes, I agree with Shane. Is there a way to get the data in order as it is in the form?

    • profile image

      Shane 5 years ago

      Thank you for this piece of script it works great, I have one question at the moment the script will e-mail the form contents but they are in what appears to be a random order ,is there a way to have them e-mailed in the order that the form is laid out. this would make for a much more organised and manageable message.

    • profile image

      aHappierLife 5 years ago

      Yes i agree, this is good stuff, thank you so much for your help

    • kzvikzvi1 profile image

      kzvikzvi1 5 years ago from SFO

      Thanks for your comment. I am glad you found this useful.

    • FalconSays profile image

      Karen S Falcon 5 years ago from Las Vegas, NV

      AWESOME! Thank You. I'm subscribing to your YT now. :-)