Last active
January 16, 2019 00:16
-
-
Save kurtkaiser/a96fb7df7f7403a82c80070812f80395 to your computer and use it in GitHub Desktop.
Automatic Email Sending Add-on with Word Detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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