I'm about to create a Google Form which will export to a Google Sheet. I want to be able to send an email notification to a specific email address (from a list of addresses) based on an answer (which would be in a cell in column C) when the form is submitted.
Example:
UserA answers first question which is required: "What region are you from?"
based on that answer, I want an email to be sent to a specific email address from a list of addresses.
If UserA answers South East an email will be sent to Bob#acme.com
If UserA answers North, an email will be sent to Betty#acme.com
If UserA answers West, an email will be sent to Frank#acme.com
Thanks.
You can use an object and test the incoming value for the Col C.
Example:
var emails ={"South East": "Mail1#some.com,
"North": "Mail2#some.com",
...
}
And then assuming the column c goes like..
var colC = e.namedValues['xxx'];
var recipient = emails[colC];
This is just the general methodology. You can also use switch statement.
You should validate the input before proceeding to confirm if the user value is valid.
Plenty of tuts available on email notification on form submit.
Related
i would like to ask about how to send email of specific Google Sheet data after Responded submit Google Form Answer
the google sheet data is collected from multiple sheets and using conditional IF or VLOOKUP or maybe QUERY
i have more than 2 sheet, just say 4 sheets (can be more)
Sheet 1 : Database
Sheet 2 : Doc X
Sheet 3 : Doc Y
Sheet 4 : Doc Z
the detail is like this
https://i.stack.imgur.com/77qBM.png
so i want to make script that do sending email automatically after responded submit the google form
in this case it would send email to JKL#GMAIL.COM
because of the secret code is ID-004
the email would be something like this
Hi here is your ID list :
DOCX-003
DOCY-003
DOCZ-003
if the data still 1 row ( ABC#GMAIL.COM ID-001 )
then it would send this
Hi here is your ID list :
DOCX-001
DOCY-001
thanks you for your insight
I am using Google App Scripts to search and reply to a going emails.
Let's say I can use GmailApp.search to search a thread by subject already and I want to reply to the first search result
I want to reply to: and cc: to specific people every time search and reply this going email. Like: to: a#gmail.com + cc: b#gmail.com, c#gmail.com.
Now I am using thread[0].replyAll because I don't know how to do as above. But always it reply to all the people of the last message of the going email ( even including me in to the cc or me in the to: if I am the last one doing message of the total email)
var subjectsearch =brandname+"/ SAMBU"+"/ MATERIAL REQUEST/ ROUND "+round+'/ '+subjectname;
var threads = GmailApp.search('subject:('+subjectsearch+')');
if (threads.length>0){
threads[0].replyAll(messagePrefix,{from:"kevin#sambu.sewing.co.kr",htmlBody: message, })
first message
If I replyall it will look like this, I dont want to send to me but always a specific to: and cc: if I want
I'm making a website for school to connect students and teachers. Teachers fill out a Google Form asking for service (grading papers...) and it is connected to Google Spreadsheets. Then a student can see that Spreadsheet and sign up on a different Google Form to help the teacher, and that response is recorded in the same Google Spreadsheet. When the student submits his/her Google Form, I want the teacher to be notified by email that a student signed up to help them. How can I send that notification? And I don't want the notification to come from my own school address. Is that possible?
Here is the Google website: https://sites.google.com/fcpsschools.net/jmhsservicesignup/subjects/math
This is the code I have so far:
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Tutors
Signed Up");
var startRow = sheet.getLastRow(); // First row of data to process
var dataRange = sheet.getRange(startRow, 1, 1, 5)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[3]; // Second column
var tutor = row[0];
MailApp.sendEmail(emailAddress,"Tutor Request Filled",""+tutor+" has accepted your request to be tutored! Please notify"+tutor+" if anything changes.");
}
}
The getLastRow doesn't seem to work, and the email sends from my own address, not a Google forms notification if that is even possible.
If this is impossible I might just make the students send the email to the teacher, but I really want to automate the process. If you can think of a workaround, that would also be awesome.
Adding to what Sandy Good and Guilherme mentioned.
Here are a few more tips:
Not clear what data you're trying to get in your function. Are you trying to grab the data from the form submission? In that case you need to set up a trigger from the scripts menu, and connect it to the function (function needs to have an 'event' argument, usually called e).
function processFromSubmission(e) {//get data from e}
Apologies if you're not trying to do that. What happens when you Log sheet.getLastRow()?
Ask the school if they can get you another email address to use for this form, something like notifications#yourschool.edu. Follow the steps here to set up your alias. Do it for the gmail account that "owns" the spreadsheet these forms are sending data to.
Make sure your alias is set up properly. You should be able to see it in the "from" dropdown menu when you compose an email. Also try running the code Logger.log(GmailApp.getAliases()) and check the log to see that it's available.
Use GmailApp.sendEmail to send email, not MailApp.sendEmail. They're almost the same, but it looks like the MailApp version doesn't let you send from an alias. You can specify the 'replyTo' email as well if you want to set it to something else, like the student filling out the form or whatever (still not clear exactly what you're trying to set up!).
Send email like:
GmailApp.sendEmail(emailAddress, subject, body,
{replyTo: replyToEmailAddress_can_be_any_email,
from: 'notifications#yourschool.edu'
});
Note: your link didn't open.
I have created an application where I am collecting form responses from various users. I am getting responses with email id in responses spreadsheet. As I don't want to store data in spreadsheet so I am reading data trough responses. I am facing some challenges please guide.
Query 1
while using onFormSubmit(e) I am not able to read submitted form, given code is returning null:
var form = FormApp.getActiveForm();
Logger.log('usename:' + form.getId());
error " Cannot call method "getId" of null." although if I hard coded value of formid var form = FormApp.openById('<<form_id_xyz>>'); then it is working fine and I can read responses as well.
How can I get form responses for multiple users?
Query 2
getRespondentEmail(); is not working in my case. Even I use form id <<form_id_xyz>> and trying to get email id from responses which I have captured at the time of form submission form.setCollectEmail(true); I tried following code in onFormSubmit(e) function but dint get a result:
var formResponse=form.response;
Logger.log('email id of user: ' + formResponses.getRespondentEmail());
and another way:
Logger.log('email id of user: ' + form.getRespondentEmail());
and
Logger.log('email id of user: ' + e.values[1]);
nothing works for me. Kindly guide.
Query 1: Hope it's clear in my comment.
Query 2:
Sorry to say, I don't understand your second query problem completely.
However as per your requirement I am suggesting this code.
If you have created a form you should know the form id (I assume) so try this code.
var form=FormApp.openById('your form id here');
//this returns your form which you created//
var responses=form.getResponses();
/// this will give you all responses of your form as an array////
///iterate the array to get respondent email id///
for(var i = 0; i < responses.length; i++){
Logger.log(responses[i].getRespondentEmail());
}
I think it's important to note that at the present time the answer to your question is: You can get what they enter, but you cannot get their true verified Email Address. This is explained better in this question and one of the answers details some workarounds such as publishing form as a web script.
The accepted answer displays what email address the user has typed into the form. There is no authentication to this beyond it having an # symbol thus a user could type foofoo#zoomZoom.com and it would be viewed in the forms results and scripts.
What's annoying is that google IS capturing the user's true email address because if settings are set to Allow One Response Per User, then the user is limited to one submission -- regardless of what they put as their email account. I'm not sure why Google won't provide a method to view the submitter's login email address since it has been disclosed to the user that this will be disclosed.
Microsoft Forms does capture this.
I would like to recreate the gmail to: type field but for entering in data to a spreadsheet. So if a person starts typing in an email address it will look at their contacts (and domain contacts) and show a filtered set of emails.
No you cant because there is no event to detect the user typing.
What you can do is add a menu item that looks at the active cell and attempt to do the autocomplete on the cell.
I wound up using Data Validation.
Get a CSV of the contacts.
Import those contacts into a sheet on the spreadsheet
use a formula similar to (= A1 & " " & B1) to create a filed that you want to search on. In my case I combined First Name and Last Name
Open a new sheet and right -click cell A1. Use data validation to pull from the column you created in the previous sheet.
just start typing in the box and it opens up like the to: field in an email box.
I did this with 400 names and saw no performance issue.