I am comparing two sheets. One sheet includes data that gets automatically extracted from an intern data storage. An arrayformula sets the status column (Sheet1!D:D) on "consent received" as soon as there is a match in the e-mail address.
Here's an example.
What I would like to do, is to get an automate e-mail notification as soon as the status was set on "consent received". Further, I would need to have the information in the e-mail, in which row of the sheet the change has been made and to limit the script only to new changes. Right now I get a notification for every "consent received" status in the column and not only for the ones that have been recently updated.
This is what I've got so far:
function sendEmail(email_address, email_subject, email_message) {
var status = ScriptProperties.getProperty('AlertStatus') + "";
var value = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("D2:D100").getValues().toString();
if (value.match("consent received") && status.match("")) {;
ScriptProperties.setProperty('AlertStatus', '')
MailApp.sendEmail('j***.bla****@m****.com', 'New Opt In', 'It seems as if there has been an Opt In. Congratulations! Please check our JCFC Sheet! ');
} else {
if (!value.match("consent received"))
ScriptProperties.setProperty('AlertStatus', '')
}
}