Created
January 30, 2018 14:39
-
-
Save ronsims2/26ae09992498b8a058bd9225e1455d0b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function remindify() { | |
var ss = SpreadsheetApp.openById('my-google-sheet-id'); | |
var sheet = ss.getSheets()[0]; | |
var cols = sheet.getMaxColumns(); | |
var rows = sheet.getMaxRows(); | |
var range = sheet.getRange(1,1, rows, cols); | |
var values = range.getValues(); | |
var to = '[email protected]'; | |
var now = new Date(); | |
var A_DAY_MS = 43200000; | |
var diff; | |
var val; | |
var cell; | |
for (var i = 0; i < values.length; i++) { | |
if (i > 0) { | |
if (values[i][0] && values[i][4] !== true) { | |
diff = Math.abs(now - values[i][0]); | |
if (diff <= A_DAY_MS) { | |
MailApp.sendEmail(to, values[i][2], values[i][3]); | |
cell = sheet.getRange(i + 1, 5); | |
cell.setValue(true); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment