I am collecting requests via Google Forms and they are stored in a Google Sheets. So whenever a new submission comes, I would like to send an email based on the choices.
Currently I have created a separate tab where country and recipient of the email exist.
In my form response tab, I wrote a formula:
=query(ArrayFormula(iferror(vlookup(B2:B;Sayfa2!$A$2:$B$4; 2; false))); "where Col1 <>''")
It looks like:
So pulling the data when a new submission comes. However, my GAS does not trigger email
//setup function
var ActiveSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
if (ActiveSheet.getName() == 'Form Yanıtları 1') {
var StartRow = 2;
var RowRange = ActiveSheet.getLastRow() - StartRow + 1;
var WholeRange = ActiveSheet.getRange(StartRow,1,RowRange,4);
var AllValues = WholeRange.getValues();
var message = ""
//iterate loop
for (i in AllValues) {
//set current row
var CurrentRow = AllValues[i];
var row = AllValues[i]
var alertRecipient = row[3];
var emailMessage= row[2];
var emailSubject = "A suggestion received for your style guide"
//set HTML template for information
message +=
"<p><b>Option: </b>" + CurrentRow[1] + "</p>" +
"<p><b>Comment: </b>" + CurrentRow[2] + "</p>" +
"<p><b>Recipient: </b>" + CurrentRow[3] + "</p>" +
"</p><br><br>";
}
}//For loop close
//define who to send emails to
// var SendTo = "[email protected]";
//set subject line
// var Subject = "New Form";
//send the actual email if message is not empty
if (message) {
MailApp.sendEmail(alertRecipient,emailSubject,emailMessage);
}//if message
}//if sheetName Review
//End Func
I set up my GAS trigger as onEdit.
Could you please help me to understand where I do the mistake?
Thanks so much in advabce!

