Google Forms Email Script

3
Creating a Form Open up Google Docs and Select “Create New Form” . Create your form with your questions. You can use any type of question in your form and the results will be emailed to the email address input by whoever fills out the form. An example form for this process is available at http://goo.go/DOzW8. Please do not alter this spreadsheet but make your own copy. Once you’ve created your questions, go back to your Google Docs list, find the form you just made and open the spreadsheet. You will see that your questions are already filled out in row 1. Click on the “Tools” dropdown menu and select “Script Editor”. This will open up the “Google Apps Script” window. Leave this page open and go to http://goo.gl/qihBj. This is the script that you need. Copy the entire page and go back to the “Google Apps Script” window. Delete all contents in this window and paste the script you just copied into the “Code” area. Click on the field at the top where you see the words “Untitled project” and give the project a name (ex. Mail script). Click the disc to save. Tip: Forms and spreadsheet icons are different. Forms Spreadsheets 2011 - Bill Bass www.mrbassonline.com Creating the Script

description

A how-to document on how to use a script with a Google Form that allows you to send an email confirmation or results based on the email input into the form.

Transcript of Google Forms Email Script

Page 1: Google Forms Email Script

Creating a Form

Open up Google Docs and Select “Create New Form” .

Create your form with your questions. You can use any type of question in your form and the results will be emailed to the email address input by whoever �lls out the form. An example form for this process is available at http://goo.go/DOzW8. Please do not alter this spreadsheet but make your own copy.

Once you’ve created your questions, go back to your Google Docs list, �nd the form you just made and open the spreadsheet. You will see that your questions are already �lled out in row 1.

Click on the “Tools” dropdown menu and select “Script Editor”. This will open up the “Google Apps Script” window. Leave this page open and go to http://goo.gl/qihBj. This is the script that you need. Copy the entire page and go back to the “Google Apps Script” window. Delete all contents in this window and paste the script you just copied into the “Code” area.

Click on the �eld at the top where you see the words “Untitled project” and give the project a name (ex. Mail script). Click the disc to save.

Tip: Forms and spreadsheet icons are di�erent.

FormsSpreadsheets

2011 - Bill Basswww.mrbassonline.com

Creating the Script

Page 2: Google Forms Email Script

There are two lines of this script that should be altered based on your needs. In line 4, the last numbermust be equal to the number of columns in your spreadsheet (including the “Timestamp”). In this case,the number “8” signi�es the number of total columns.

In line 22, change the text in quotation marks (ex. “Answers to mail merge form”) to whatever text is desired for the subject of the email to be sent. Quotation marks are essential to the the script.

Save script again and close the Google apps script window. The script must be saved for it to work.

Open back up the spreadsheet that is associated with the desired form and create a new sheet by clicking the symbol. Rename this sheet, “Email template”, by clicking on the small arrow on the right side of tab.

Open a new browser tab and go to http://goo.gl/la2Px. Copy all of the text below the horizontal line. This is the email that will be sent to the email address entered into the form. Double click on cell A1 in the “Email Template” sheet on the spreadsheetand paste this text.

2011 - Bill Basswww.mrbassonline.com

Email Script for Google Form

8 columns in spreadsheet =

Compose the email

Rename Add sheet

All text found outside the brackets and quotation marks is completely customizable by you. The text inside the quotation marks must be identical to the �rst row of the spreadsheet for the script to pull the correct information. Add lines as needed based on the information to be emailed.

Page 3: Google Forms Email Script

The form is now ready to accept submissions. As the form is �lled out, each line of the resulting spreasheet will �ll in based on the information. Once all data is in the spreadsheet and you are ready to send information via email, it’s time to run the script.

Select the “sendEmails” script from the “Script Manager” list and click on “Run” at the bottom of the window. The �rst time you run this script you will have to authorize it to run. Click “Authorize” and then click “Run” again from the “Script Manager”. While it may not seem like anything has happened, emails will be sent to each email in its own row on your spreadsheet.

2011 - Bill Basswww.mrbassonline.com

Email Script for Google Form

Running the Script

Note: Any time this script is run, an email will be sent to all emails on the list unless those rows are deleted or cleared. It’s not possible to only send speci�c rows With this script (to the best of my knowledge).

For an example, go to http://goo.gl/DOzW8 and make a copy of this spreadsheet to work with. Please do not alter the existing form or spreadsheet.

Note: The script can also be run by going to the “Script editor”, select “Run” and select “sendEmails”. A message will display at the top of the window verifying that the script is running.

In the spreadsheet, select “Tools” then “Script manager” from the dropdown. This will open up a new window with all the scripts available in this spreadsheet.