Apps Script example · 5 min read

Send a Confirmation Email When a Form Is Submitted: Copy-Paste Apps Script Pattern

Working send a confirmation email when a form is submitted example in Apps Script—copy-paste code, common mistakes, and when to get it built professionally.

FormsMailAppNotifications

Respondents who fill out a request or signup form generally want some reassurance that their submission actually went through, and a manual reply from a person hours later rarely arrives fast enough to provide that.

This script hooks into the same onFormSubmit trigger event used elsewhere in this series, but focuses specifically on reading the respondent's own email address and name to send them an immediate confirmation message.

Rather than the generic notification Google Forms can optionally send to the form owner, this is a message addressed to the person who just submitted the form, written to sound like a real reply rather than an automated receipt.

The email includes a short summary of what they submitted, pulled straight from the same namedValues object the trigger already has access to, so the respondent can double-check their answers were captured correctly.

Need this built? Hire a Google Apps Script developer →

Sheet / project setup

Form settingValueRole
Collect email addressesOne.response.getRespondentEmail()
Question: Full NamenamedValuesGreeting
Question: TopicnamedValuesSubject line

What It Does

Whenever the form is submitted, the trigger reads the respondent's email address and name from namedValues, builds a short confirmation message summarizing the key fields they filled in, and sends it with MailApp.sendEmail.

The summary section of the email is generated dynamically by listing each mapped field and its answer, so the confirmation always reflects the actual current questions on the form rather than a hardcoded description.

Prerequisites

Your Google Form needs a question that collects the respondent's email address, since MailApp.sendEmail requires a real recipient address and Forms does not automatically expose the submitter's account email unless you explicitly ask for it.

Draft your confirmation subject line and opening sentence ahead of time so the email reads naturally rather than like a raw data dump of form fields.

Walkthrough

Paste the sendConfirmationEmail function into the script editor and update EMAIL_FIELD_TITLE and NAME_FIELD_TITLE to match the exact question titles used on your form for email and name.

Add an installable On form submit trigger for this function through the Triggers menu, separate from any other onFormSubmit trigger you may already have configured for sheet processing.

Submit a real test response using your own email address and confirm the confirmation message arrives promptly with the correct name and a readable summary of your test answers.

Edge Cases

If the email field question is left blank because a respondent skipped an optional field, the script logs a warning and skips sending rather than calling MailApp.sendEmail with an empty recipient address.

Long free-text answers included in the summary are truncated to a reasonable length so the confirmation email stays scannable instead of reproducing an entire paragraph back to the respondent.

Testing

Submit a form response with every optional field filled in and confirm the summary section in the confirmation email lists all of them accurately and in the expected order.

Submit a second response leaving the optional fields blank and confirm the confirmation email still sends successfully with just the required fields summarized.

Hardening

Add a simple email format check with a regular expression before calling MailApp.sendEmail, since a mistyped address in a free-text email field would otherwise cause the send call to throw.

Track daily MailApp.sendEmail usage against your account's quota if form volume is unpredictable, since exceeding the daily email quota causes sends to fail silently for the rest of that day.

Variations

Switch from MailApp to GmailApp.sendEmail if you need to send from a specific alias or attach a generated PDF receipt to the confirmation.

Combine this trigger with the create-task-from-form tutorial so the same submission both confirms receipt to the respondent and queues internal follow-up work at the same time.

sendConfirmationEmail.gs

sendConfirmationEmail reads the respondent's own email and name from the submission event, builds a short summary of selected fields, and sends it back with MailApp.

// Email the respondent a confirmation summary on form submit
function sendConfirmationEmail(e) {
  var EMAIL_FIELD_TITLE = 'Email Address';
  var NAME_FIELD_TITLE = 'Full Name';
  var SUMMARY_FIELDS = ['Department', 'Request Type', 'Details'];

  var namedValues = e.namedValues;
  var email = namedValues[EMAIL_FIELD_TITLE] ? namedValues[EMAIL_FIELD_TITLE][0] : '';
  var name = namedValues[NAME_FIELD_TITLE] ? namedValues[NAME_FIELD_TITLE][0] : 'there';

  if (!email) {
    Logger.log('No email address found; skipping confirmation send.');
    return;
  }

  var summaryLines = [];
  for (var i = 0; i < SUMMARY_FIELDS.length; i++) {
    var value = namedValues[SUMMARY_FIELDS[i]];
    if (value) {
      var text = value[0].length > 120 ? value[0].substring(0, 120) + '...' : value[0];
      summaryLines.push(SUMMARY_FIELDS[i] + ': ' + text);
    }
  }

  var body = 'Hi ' + name + ',\n\nThanks for your submission! Here is what we received:\n\n' +
    summaryLines.join('\n') + '\n\nWe will be in touch soon.';

  MailApp.sendEmail(email, 'We received your submission', body);
}
  1. Line 8: Falling back to an empty string when the email question was skipped is what lets the very next check decide whether to bail out safely.
  2. Line 11: Bailing out before calling sendEmail is essential, since MailApp.sendEmail throws immediately if given a blank recipient address.
  3. Line 20: Truncating any answer longer than 120 characters keeps the summary section scannable instead of reproducing an entire paragraph.
  4. Line 21: Building the summary as one line per field is what lets the respondent verify each of their answers was captured correctly.
  5. Line 28: MailApp.sendEmail is used here instead of GmailApp specifically because this send does not need a custom alias or attachment.

Deploy this example

  1. 01

    Open Apps Script

    In the bound spreadsheet: Extensions → Apps Script. For standalone projects, create one at script.google.com and link your Sheet by ID.

  2. 02

    Paste and save

    Add a .gs file, paste the code below, rename constants at the top (sheet names, column letters, API property keys), then save.

  3. 03

    Authorize once

    Run the main function from the editor. Accept OAuth scopes when prompted — triggers cannot run until authorization succeeds once.

  4. 04

    Add the trigger

    Triggers → Add trigger → choose the handler function and event (time-driven, on edit, or on form submit). Delete test triggers before production.

Before you run: send confirmation email

  • 1Form includes a question collecting the respondent's email address
  • 2Confirmation subject line and opening sentence drafted ahead of time
  • 3EMAIL_FIELD_TITLE and NAME_FIELD_TITLE matched to exact question titles
  • 4Installable On form submit trigger added for this specific function
  • 5Test submission confirmed the confirmation email arrives promptly
  • 6Blank-email edge case tested to confirm the send is skipped safely

Frequently asked questions

The script logs a warning and skips sending rather than calling MailApp.sendEmail with a blank recipient.

Switch to GmailApp.sendEmail, which supports sending from a verified alias, as noted in the variations section.

No, that owner notification is a separate Forms setting; this script addresses the respondent directly instead.

They are truncated to a reasonable length so the confirmation email stays scannable rather than reproducing an entire long answer.

Yes, switch to GmailApp.sendEmail and attach a blob, such as a PDF generated by the export-slides-to-pdf pattern or a filled template document.

Sends fail silently for the rest of that day, so track usage against your quota if form volume is unpredictable, as noted in the hardening section.

Related examples

Want this wired into your real workflow?

I adapt these patterns to your Sheet structure, APIs, and triggers — deployed in your Google account. Fixed-scope quotes from $500 · free 30-min consult · quote within 24 hours.