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.
https://www.googleapis.com/auth/spreadsheets • https://www.googleapis.com/auth/gmail.sendfunction 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
Step-by-Step Setup & Deployment
- Link your Google Form to a Google Sheet (Responses > Link to Sheets).
- In the linked spreadsheet, open Extensions > Apps Script and paste this code.
- 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()orsetValue()inside loops. Read ranges into memory in 1 call, process arrays in V8 memory, and commit changes with a singlesetValues()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
Automatically Close Google Form When Max Submissions Reached
Tracks event registrations or survey entries and automatically closes the Google Form and displays a custom "Event Sold Out" message when capacity is reached.
Google FormsPopulate Google Forms Dropdowns Dynamically from Spreadsheet
Reads dynamic inventory, available event time slots, or staff names from Google Sheets and automatically updates dropdown choices in an active Google Form.