Answers / Question 5
Email the full answers of each Google Form response, not just a notification
Google Forms only tells you a response arrived. This short Apps Script emails every answer, with Reply going straight to the respondent.
The problem
You want each completed form to land in someone's inbox with all of its answers, so they can act on it without opening the response sheet. The built-in notification only says that a new response exists.
Inspired by a public question on Google Docs Editors Community. The problem above is described in our own words and the solution below is ours.
The fix
- Open the spreadsheet linked to the form (in the form: Responses → Link to Sheets).
- Extensions → Apps Script, paste the code, and set
to. - Run
installFormTriggeronce and approve. Every new submission now emails each question and answer.
// Email the full answers of every Google Form response (not just "you have a new response").
// Put this in the response spreadsheet: Extensions > Apps Script.
const FORM_MAIL = {
to: 'team@example.com',
subject: 'New form response'
};
function formatAnswers(namedValues) {
return Object.keys(namedValues)
.filter(function (q) { return q !== 'Timestamp'; })
.map(function (q) { return q + ': ' + [].concat(namedValues[q]).join(', '); })
.join('\n');
}
function onFormSubmitHandler(e) {
const nv = e.namedValues;
const email = String((nv['Email Address'] || nv['Email'] || [''])[0]).trim();
const options = {};
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) options.replyTo = email; // Reply goes to the respondent
MailApp.sendEmail(FORM_MAIL.to, FORM_MAIL.subject, formatAnswers(nv), options);
}
// Run once from the editor and approve the permissions.
function installFormTrigger() {
ScriptApp.newTrigger('onFormSubmitHandler').forSpreadsheet(SpreadsheetApp.getActive()).onFormSubmit().create();
}
If the form collects an email address (a question named Email, or the built-in Email Address), pressing Reply on the notification writes straight back to the respondent.
Good to know
- Run the installer only once. Running it again creates a second trigger and you'll get two emails per response (remove extras under the clock icon).
- Scripts on a free Gmail account can email about 100 recipients a day; Google Workspace accounts get more.
- Questions with multiple answers (checkboxes) are joined with commas.
The script's logic is unit-tested against a simulated spreadsheet before publishing. Always try new automations on a copy of your sheet first.