Google Forms AutomationDifficulty: Beginner⚡ On Form Submit (Event Trigger)

Google Forms: Automated Dynamic Email Confirmation on Submit

Listens for Google Form submissions, extracts respondent name, email, and requested service, and dispatches a personalized HTML confirmation receipt immediately.

Required OAuth Scopes: https://www.googleapis.com/auth/spreadsheets • https://www.googleapis.com/auth/gmail.send
Code.gs (Apps Script V8 Runtime)
function onFormSubmitAutoResponder(e) {
  // e.values index: [0: Timestamp, 1: Email, 2: Name, 3: Service, 4: Notes]
  const userEmail = e.values[1];
  const userName = e.values[2];
  const service = e.values[3];
  
  const subject = 'Confirmation: We received your request for ' + service;
  const htmlBody = '<div style="font-family: Arial, sans-serif; line-height: 1.6; color: #1e293b;">' +
    '<h2>Thank You, ' + userName + '!</h2>' +
    '<p>Your inquiry regarding <strong>' + service + '</strong> has been recorded.</p>' +
    '<p>Our team will review your specifications and contact you shortly.</p>' +
    '<hr style="border: 0; border-top: 1px solid #e2e8f0; margin: 20px 0;" />' +
    '<p style="font-size: 12px; color: #64748b;">GoogleSolution Automated Workflow</p>' +
    '</div>';
    
  GmailApp.sendEmail(userEmail, subject, '', { htmlBody: htmlBody });
}

Line-by-Line Code Explanation

Line 1: Receives event object `e` automatically injected by the Google Forms submission trigger.
Line 3-5: Unpacks submitted values according to spreadsheet column sequence.
Line 7-14: Constructs a responsive HTML email message with custom recipient variables.
Line 16: Dispatches the email via GmailApp with zero delay.

Step-by-Step Setup & Deployment

  1. Link your Google Form to a Google Sheet (Responses > Link to Sheets).
  2. In the linked spreadsheet, open Extensions > Apps Script and paste this code.
  3. Click Triggers > Add Trigger > Select onFormSubmitAutoResponder > Event source: From spreadsheet > Event type: On form submit.

Best Practices for Quota & Rate Limit Management

When deploying this automation in Google Workspace, adhere to these operational principles:

  • Batch Reads & Writes: Never execute getValue() or setValue() inside loops. Read ranges into memory in 1 call, process arrays in V8 memory, and commit changes with a single setValues() call.
  • Execution Timeouts: Apps Script terminates scripts exceeding 6 minutes. For multi-thousand row datasets, implement batch pagination with resume timestamps stored in PropertiesService.
  • OAuth Permissions: Scope your manifest (appsscript.json) narrowly to prevent security prompts from alarming external team members.

Frequently Asked Questions

Is Google Apps Script completely free to use?

Yes. Google Apps Script is built into all free Google accounts and Google Workspace editions. There are no server fees or subscription costs for running scripts within daily quotas.

Can I run this script on an automated schedule without keeping my computer on?

Yes. Time-driven triggers execute on Google's cloud infrastructure. Your script will run reliably even when your computer is closed or offline.

More Google Forms Automation Snippets