I am using Google Forms to run a customer database. When the costumer called me, I am editing the same Google Form entry. So I would like to find out how this change or entry of a particular cell can trigger the mail script which I will post here. It should only trigger once, in the moment of change.
Edit:
I have add the "if" now, and set the trigger to Form Submit. Now, if I am changing in the Google Form the value to "test" and sent the form a email is sent to me. But how can I specify this for each entry if I have several email address in the form. Also that it does not send double?
function sendArticleCountEmails() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSheet(ss.getSheetByName("Test"));
var sheet = SpreadsheetApp.getActiveSheet();
var dataRange = sheet.getRange("A2:F4");
var data = dataRange.getValues();
var currentValue = sheet.getRange("J2").getValue();
if (currentValue == ("test"))
for (i in data) {
var rowData = data[i];
var emailAddress = rowData[1];
var recipient = rowData[0];
var message1 = rowData[2];
var message2 = rowData[3];
var parameter2 = rowData[4];
var message3 = rowData[5];
var message = 'Dear ' + recipient + ',\n\n' + message1 + ' ' + message2 + ' ' + parameter2 + ' ' + message3;
var subject = 'Your article count for this month';
MailApp.sendEmail(emailAddress, subject, message);
}
}
I have several email address in the formwhat do you mean? Where are the email addresses stored? Also, when you saynot send double, under what circumstances would the script send double? - I hope this is helpful to youifworks on change and trigger the send, but how can I specific it on for each row? - Seb