ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

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


      4 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


      4 years ago

      for(var field in e.namedValues) {

      It is showing error for me. Any one help me

    • profile image

      need help 

      5 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


      5 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


      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


      6 years ago

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

    • kzvikzvi1 profile imageAUTHOR


      6 years ago from SFO

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

    • FalconSays profile image

      Karen S Falcon 

      6 years ago from Las Vegas, NV

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


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)