How To Automatically Send Email To The Respondent On Google Form Submission ?

Google forms are one of the most used forms for collecting data but do you know that you can send confirmation form to the respondent on form submission and look like a professional.

There are many add ons for sending the email to the respondent on form submission like Email Notifications For Google forms but do You Know that You can  write your custom Script For sending Email to the respondent.

Welcome Guys You are at Techsyapa and Today we will talk about how to write a custom script for sending emails to the respondent. As we all Know that the data entered on Google forms are stored in Google sheets, so we will automate the google sheets to send emails.

So here is the step by step Procedure For Automating Google Sheets :-

1. Open the Google sheet which is linked with Google Form.

2. At the top of the Google sheet You will see a navigation bar , in navigation bar their will be a option of Tools , from Tools open script editor.
Navigation bar -> Tools -> script editor
3. Then You will see a default file named code.gs, before moving forward here is the look of my google sheet which correspond to my google form.




As we can see that there are 3 Columns named Timestamp , Email Address and Name , Now coming Back to code.gs , copy paste the code given below in code.gs.


This is the script for Automating emails , You can customize the script according to your google sheet and your needs. Make the following changes according to your needs :-
a). change the number of column of getrange function to total number of columns in Your sheet(Usually the 1 st column is of timestamp in this script we are not using timestamp column as you can see in getrange function our starting column is 2 not  1 if you are using start column as 1 then change total number of columns to total number of columns in your sheet+1).

b). In our case email address was stored in 2nd column and in getrange function we have entered the starting columns as 2 so  that's why in emailaddress variable we have entered row[0]. So  you should update the value of emailaddress variable according to the location of email address column in your google sheet.

c). In tmp2 variable we have stored the name of the user , which is present in column 3 in our case. You should update the value according to the location of name in your google sheet.

d). change the subject of your email.

After customizing your script run your sendemail2 function , it will ask for authorization allow the  script to access the sheets and send email on Your behalf.

4) In navigation bar click on edit and select current project trigger, a  new tab will open.
navigationbar -> edit -> current project triggers
5) In the tab opened there will be a option of creating a trigger click on it. And then select sendemails2, From spreadsheet ,onformsubmit.



Hurray !!!! you have successfully setup the automatic Email Sending Mail System.

You can modify this script for automating the google sheets, for example if you want to send an email to your respondents daily then you can create a time based trigger for it which will send them emails automatically at your given time. This is only one example you can do a lot with google sheets using triggers.

For any queries or suggestions feel free to write it in comment section. 





Comments

Popular posts from this blog

How To Run Jupyter Notebook , Pandas And Numpy On M1 MacBook ?

M1 MacBook Air For Development (A Student Review)

How To Securely Send An Email From Gmail