Automatic Email Sending Add-on with Word Detection

Automatic Email Sending Add-on with Word Detection

Google Apps Scripts is a powerful tool. All you need is a basic understanding of JavaScript and you can create any add on your heart desires.

Hoping to make Google Apps Script more accessible, I started a new project. This create a simple application that notifies you when a user has submitted a particular word to a Google Form. I plan on adding more features and will be posting tutorials as I add on to the project.

Feel free to copy / steal / edit / mock the code to your liking.

// 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: “kurtbkaiser@gmail.com”,
subject: “Alert – Friday Requested”,
body: “Someone has requested Friday.”
})
}

// —————————————-

function main() {
if (checkSubmission()) {
sendAlertEmail();
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *