Sending Confirmation Emails with a Google Docs Form

Posted on Jun 18, 2011 in Tech Tips & Tricks | 288 comments

Screenshot of a Google Apps Script

I love Google Apps. Gmail, Google Docs, Google Voice–all brilliant, indispensable products in my opinion.  Being able to create forms in Google Docs for quick polls and surveys is also very handy, but the extremely limited feature set has been frustrating to me. One surprising lack is that of being able to send a confirmation email to the user. Granted, not all forms necessarily even have a field for the user to enter their email.

[Original post 6/18/11. Edited 10/29/11 to add HTML email to the example. Edited 4/21/12 to add more screenshots and correct "Triggers menu" to "Resources menu".]

With a quick script, you can rectify this and customize an email that will be sent to the user. Don’t be intimidated by the code–if you can handle writing raw HTML, you will be able to modify this script to suit your needs.

However, if you’ve never used a Google Form before, you probably want to play around with that and get comfortable with that first. The rest of this assumes that you have created a form and are viewing the attached spreadsheet.

Update: make SURE you are looking at the spreadsheet, as shown in the screenshot below. If you are viewing the form, you are in the wrong place. The script needs to be attached to the spreadsheet. Thanks to t1dude for pointing this out!

Screenshot - how to open the Script Editor in Google Docs
The first step, in Google Docs, is to click on “Tools” and then “Script Editor.” A new window will open, with an empty function called “myFunction.” Overwrite the contents of this window with the code you want to use. Below I’ve added a complete example that you can rework to your needs.

function onFormSubmit(e) {
var timestamp = e.values[0];
var yourName = e.values[1];
var toAddress = e.values[2];
var eventName = e.values[3];
var visitDate = e.values[4];
var visitComments = e.values[5];
var subject = "CAP Confirmation - " + eventName + " " + visitDate;
var emailBody = "Thank you for your Club Ambassador Program report submitted on " + timestamp +
"\n\nThe details you entered were as follows: " +
"\nYour Name: " + yourName +
"\nYour Email: " + toAddress +
"\nClub or Event Name: " + eventName +
"\nVisit Date: " + visitDate +
"\nVisit Comments: " + visitComments;
var htmlBody = "Thank you for your <b>Club Ambassador Program</b> report submitted on <i>" + timestamp +
"</i><br/>&nbsp;<br/>The details you entered were as follows: " +
"<br/><font color=\"red\">Your Name:</font> " + yourName +
"<br/>Your Email: " + toAddress;
var optAdvancedArgs = {name: "Club Ambassador Program", htmlBody: htmlBody};
MailApp.sendEmail(toAddress, subject,
emailBody, optAdvancedArgs);

Screenshot - Script Editor after pasting sample script
See the first section, with “e.values”? Those refer to the form fields. “e.values[0]” will always be the timestamp. “e.values[1]” will be the first field in your form, and so on.

Feel free to change the variable names. If the first form field isn’t the respondent’s name, but is actually their favorite color instead, you can certainly change it from yourName to faveColor. Just make sure to change all occurrences of the identifier.

If you have fewer form fields, remove the lines you don’t need. If you have more, copy and paste the existing lines, making sure to increment the numbers… so “e.values[27]” would be the 27th form field, and so on. You do not need to reference every form field in your script–just have lines for the ones you want to include in the email.

Next, we put together some strings (a string of words) to be put into the email. If the text is in quotation marks, it will appear just like you entered it. If the text is not in quotation marks, then it refers to one of the variables we just set up. Plus signs concatenate those strings, and every line needs to end in a semicolon.

“\n” is special. In quotation marks, this refers to a newline character… a line break. Add that whenever you would press “enter” in the email if you were writing it by hand.

Modify the “subject” line as necessary. Yours might be simpler or more complex.

Modify the body section as necessary. This was broken up into multiple lines just for readability. It could all be on one line. Just make sure to have plus signs to connects different strings of text, and only to have one semicolon (at the end).

The “optAdvancedArgs” section is special. It refers to special settings (anything beyond the basic to, subject and body settings) for an email. You don’t have to use it. You can simply remove that, changing that line to:

MailApp.sendEmail(toAddress, subject,

Want to set other advanced arguments, like a cc line, an HTML body for the email and more? View the MailApp Script Reference and scroll to the bottom of the page for a list of what you can set and examples of how to use them.

A few notes on HTML emails:

  • If you provide an HTML version of the email, also provide plain text for those email clients that can’t see the HTML version.
  • Emails don’t work like web pages. Writing HTML for an email is like making a website in the 90′s. Read the linked article or do some Googling to find out what tags you should and shouldn’t use.
  • Email clients tend to be narrow. Don’t count on having much horizontal space.
  • When you are writing a Google Docs script and need to refer to a quote character, such as when writing attributes in an HTML tag, use a backslash before the single or double quote, or else Google Docs will think you’re ending the string. Check the example for when a font color is added to “your name”

Modify the script, and then save it. However, there is one more important step to take to get this to work!
Screenshot - Triggers Menu
In the script editing window (not the normal Google Docs window), click on the “Resources” menu. Click “Current Script’s Triggers…” and then “Add a new trigger.”
The first field should be “onFormSubmit,” the second “From Spreadsheet” and the third “On form submit.” Change these if necessary and add the trigger. You will need to give your approval for Google to allow the form to send emails.

If you do not set the trigger, the script will never run. The trigger is necessary to run the code whenever a form is submitted.

There! Now try submitting a form and make sure the email looks the way you want.


  1. First of all I would like to say awesome blog!
    I had a quick question in which I’d like to ask if you don’t mind.
    I was interested to find out how you center yourself and clear your head prior to writing.
    I’ve had a tough time clearing my mind in getting my thoughts out there.
    I do take pleasure in writing however it just seems like the first 10 to 15 minutes are generally wasted simply just trying to
    figure out how to begin. Any recommendations or hints?

  2. Those who rrun good quality anti-viruses onn their
    computers will more than likely not have as
    much problem with viruses and should look to another source for
    their slow computer. As great as the Android tablets are, there is one thing that
    they ‘ like other tablets ‘ are missing. Sometimes a virus might just corrupt data
    and files so they’re irreparable, and sometimes they might just muddy the waters
    off your computer to slow it down and become frustrating and irritating for its operator (aka you).
    Wired Equivalent Privacy was introduced in
    1997 and is the original version of wireless network security.
    Or, should you be anything lijke me, you won’t ever took the
    time to memorize your Blac – Bery PIN, so you’re forced tto visit Options after which Status on your Black – Berry menu anyy time you
    must hunt for the answer.

  3. This is in fact the reality! That’s precisely whats occurring in todays society.

    Many thanks for letting us understand.

  4. I don’t even know how I ended up here, but I thought this post was great.

    I don’t know who you are but certainy you are going to a famous blogger if you are not already ;) Cheers!

  5. Remarkable! Its genuinely remarkable article, I have got
    much clear idea concerning from this paragraph.

  6. Quality posts is the important to be a focus for the viewers to
    go to see the website, that’s what this site is providing.

  7. The design is also purely sterilized to provide optimum safety to the patients lying over its surface.
    Unlike surgery that is invasive and involves several risks, the chiropractic treatment for Lumbar disc herniation benefits from its drug-free and natural methods of providing healthcare.

    when the spinal injury occurs from accidents, falls, tension, over-exertion, the inability of the spine to compensate can result in changes
    in movement or position of the vertebrae.

  8. I am extremely inspired together with your writing abilities and also
    with the format in your weblog. Is this a paid subject matter
    or did you customize it your self? Either way stay up the excellent quality writing, it’s uncommon to see a great weblog like this
    one these days..

  9. Hello, I would like to subscribe for this blog to get hottest updates, thus where can i do it please

  10. It is prudent to read the contract documents.

    Framing, walls, number of doors that’ll be mandatory, no matter
    what you need and do it without going broke. This hut was created during World War II, industrial metal buildings have several benefits
    when compared against the more traditional wooden buildings.

    If you want a standing seam roof or the screw down roofing panel is the most crucial part of your decision.
    It takes less time in the construction of Pre-engineered steel buildings are much decrease
    maintenance and will provide you with a structure without breaking any laws.

  11. Can I simply say what a comfort to discover someone who genuinely knows what they are talking about
    over the internet. You certainly know how to bring a problem to light and
    make it important. More and more people need to check this out and understand this side of
    the story. I was surprised that you’re not more popular because you most
    certainly possess the gift.

  12. You actually reported that well!

  13. For some people at some times, it is precisely this different sort of relationship
    that is needed for the conversation to happen. Natália Rita stays with the CPPD (UK) Counselling School
    where she is taking the Advanced Diploma in Humanistic Integrative Counselling.
    But for many other people, there are times when this may not be

  14. Wow, amazing blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web site is magnificent, as well as
    the content!

  15. What’s up, this weekend is good in support of me,
    as this occasion i am reading this enormous educational post here at
    my residence.

  16. This is really interesting, You’re a very skilled blogger.
    I have joined your rss feed and look forward to seeking more of your magnificent
    post. Also, I have shared yolur ebsite in my social networks!

  17. It’s an amazing piece of writing for all the internet people; they will obtain advantage from it I am sure.

  18. Hello this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if
    you have to manually code with HTML. I’m starting a blog soon but have no coding expertise so I wanted to get guidance from someone with experience.
    Any help would be greatly appreciated!

  19. Well, I think their tutorial is much more detailed than mime.

    During his journey, the boy learns about the language of the world,
    omens and pursuing his Personal Legend. Even surviving life right now seems all-important we can’t avoid thinking about different versions of “the Afterlife.

  20. And always make sure it’s 100% organic (some companies load their
    superfood up with Niacin and other non-organic components — go for the organic green superfood and avoid
    the Niacin hangover). Part of the confusion about superfoods comes from the fact that they are often backed up by some
    legitimate scientific research; however, the conclusions may be blown
    way out of proportion, becoming dubious claims eagerly accepted
    as fact. You need to have a number of superfoods in your diet daily.

  21. Wow, awesome blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web site
    is fantastic, as well as the content!

  22. Thank you, I’ve recently been looking for info approximately this subject for a while and yours is the best I have discovered till now.
    However, what concerning the conclusion? Are you positive about the supply?

  23. Awesome blog! Do you have any recommendations for aspiring writers?
    I’m hoping to start my own site soon but I’m a little lost on everything.

    Would you propose starting with a free platform like WordPress or go for a paid option?

    There are so many options out there that I’m totally overwhelmed ..
    Any suggestions? Appreciate it!

  24. Hola estoy encantada de visitar vuestra web me parece super buena.

    Yo soy una escolar universitaria que me encanta el desarrollo web, el diseño y sobre
    todo la creación de aplicaciones de juegos para móviles.

    Me gusta mucho vuestra web me parece super interesante.

    Os felicito por vuestra web, soy desde ahora una admiradora vuestra.

    Hola me ha gustado mucho tu articulo
    Es alucinante, buena aclaración la que he
    encontrado. Muchos besitos.
    Por fin alguno que me lo ha explicado para que yo lo puede comprender.
    Estoy excesivo contenta.
    Grande, que contenta estoy, es lo mas. Muchas

  25. It’s really a nice and helpful piece of information.
    I’m happy that you shared this useful info with
    us. Please stay us informed like this. Thanks for sharing.

  26. However, prolonged and frequent sufferers may need to go through operation to
    clean up the nasal sinuses. Treatment for nasal polyps is often provided through medications that can reduce the size of
    the polyp or even eliminate it. In fact, fungal sinusitis is quite common only to patients who are immuno-compromised (meaning their immune system is weak) due to some
    other illnesses like HIV-AIDS or cancer.

  27. I’m not that much of a online reader to be honest but your
    blogs really nice, keep it up! I’ll go ahead and bookmark
    your site too come back later. All the best

  28. Hello it’s me, I am also visiting this website daily,
    this site is actually fastidious and the viewers are truly sharing good thoughts.

  29. What’s up, its good piece of writing regarding media print, we all know
    media is a great source of information.

  30. Right away I am going away to do my breakfast,
    later than having my breakfast coming again to read other news.

  31. I suggest that you change your vegetarian weight loss diet every
    2 – 3 days to avoid hitting a weight loss plateau. For example, there is evidence that patients with Crohn’s disease, which
    causes inflammation in the gastrointestinal tract, can
    benefit from a high-calorie liquid diet. The Potato Museum’s mission is to educate the world about the

  32. Spot on with this write-up, I seriously think this site needs far more attention.
    I’ll probably be back again to read through more, thanks
    for the advice!

  33. Martial arts are seen as expressions of valor, chivalry, and self-sacrifice.
    So while moving forward one must be aware of the rear, and be
    prepared to retreat, while attacking being prepared to defend,
    and while defending being poised to strike. There has been a lot
    of concern with the increasingly ‘Internet addicted’ youth of the
    world, be they Chinese who died after playing too much World Of Warcraft or
    your average teen, surfing the web for hours each day after getting back from

  34. An electric tram takes visitors through numerous caverns filled with stalactites, stalagmites, subterranean lakes, streams and
    spectacular rock formations. You can mingle with the local folks
    and partake of the culture that is always on show. the important thing is that you, your partner, your loved ones and friends have a great

  35. It discussed ‘self-actualization’ longer than it
    should have, which is a really sudden gear-away from the primary concept of the program
    regarding what to do in a relationship. Most soldiers are periodically transferred to a new
    base in a different region of the country. These include
    small goals that should be sought after right now and larger goals that can
    be a little more open in terms of how long it might take
    to achieve them.


  1. Forms confirmation | Info007cleanin - [...] Sending Confirmation Emails with a Google Docs Form | AlamoxieJun 18, 2011 … One surprising lack is that of …
  2. Project 2, Day 1 – Codecademy and Javascript | An Hour Each Day - [...] no quick and easy way to do this in Google Docs forms, but there’s a great little tutorial here …
  3. Using Google docs to send email « News Apps Blog - [...] I thought it was a pretty cool solution and sounds like something that would be helpful to other folks, …
  4. Send Confirmation Emails upon submission of Google Form…. » Open School Sites - [...] [...]
  5. Google app script – how to count number of google form response | - [...] copied code from a tutorial. But need help to get the count of form responses. Here is how it …
  6. Beware of Secret Clauses in On-line Vehicle Auctions | 99th Level Gaming - - [...] you have any questions about wherever and how to use seized car auctions michigan, you can call us at …

Submit a Comment

Manage your comment subscriptions