r/GoogleAppsScript • u/arttechadventure • Apr 19 '24
Guide Generate an email from Google Forms responses.
I looked around the internet for days trying to figure out how to make this happen before finally just paying someone on fiverr to write the script for me.
Since there were a lot of people in a lot of different forums asking for the same thing, and all the answers were really confusing...here is the simple solution I purchased on fiverr.
The app script is applied to the script editor of the Google Form itself. There is no spreadsheet associated with it.
You can change 'test@email.com' to whatever email address (or addresses separated by commas) near the bottom of the script. You can rename the form from 'Matchbox Paitning Form' to whatever you'd like.
Once the script is pasted in, set up an "onform submit" trigger to run the script whenever the form is submitted.
That's all there is to it!
function onFormSubmit(e) {
var formResponse = e.response;
const itemResponses = formResponse.getItemResponses();
// Constructing the HTML body
var html = '<h1>Form Responses</h1><ul>';
// Iterates over the item responses.
for (const itemResponse of itemResponses) {
html += `<li><strong>${itemResponse.getItem().getTitle()}:</strong> ${itemResponse.getResponse()}</li>`;
}
html += '</ul>';
// Sending the email with HTML body
GmailApp.sendEmail('test@email.com','Matchbox Painting Form','Requires HTML', {
htmlBody: html
})
}
1
u/143-_-BG Apr 26 '24
I needed to be able to do this too and set it up in Zapier in about 15 minutes, including testing. Free.
1
u/flippergoalie Feb 07 '25
Hey, I'm trying to figure this out and am struggling to get anything to work (I've never used script before and am trying to lear just to do this). Would you mind helping me out via dm and/or discord?
1
u/Firm_Visual2561 Apr 20 '24
do you know any programming?
0
u/[deleted] Apr 19 '24
[deleted] — view deleted comment
1
u/[deleted] Apr 30 '24
[removed] — view removed comment