Skip to content

Instantly share code, notes, and snippets.

@kurtkaiser
Last active January 16, 2019 00:16
Show Gist options
  • Save kurtkaiser/a96fb7df7f7403a82c80070812f80395 to your computer and use it in GitHub Desktop.
Save kurtkaiser/a96fb7df7f7403a82c80070812f80395 to your computer and use it in GitHub Desktop.
Automatic Email Sending Add-on with Word Detection
// Word Based Email Alert System
// Kurt Kaiser, 2019
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
// Go through recent submission, check for alert word
function checkSubmission() {
for (var i = 1; i & lt; lastColumn; i++) {
Logger.log(sheet.getRange(lastRow, i).getValue());
if ("Friday" == sheet.getRange(lastRow, i).getValue()) {
return true;
}
}
}
function sendAlertEmail() {
MailApp.sendEmail({
to: "[email protected]",
subject: "Alert - Friday Requested",
body: "Someone has requested Friday."
})
}
// ----------------------------------------
function main() {
if (checkSubmission()) {
sendAlertEmail();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment