Your renewals, contracts and certificates probably already live in a spreadsheet. The problem is that nobody opens the sheet on the right day.
Google Sheets has no built-in "email me N days before this date" feature, but Apps Script can do it, for free, on Google's servers, even while the sheet is closed. This post builds a small version you can copy in about ten minutes:
- a daily time-driven trigger
- several lead times per row (for example 30, 7 and 1 days before)
- a "last notified" column, so a row is never emailed twice
- one email per person per day, however many items are due
- date handling that does not break around midnight or at daylight-saving changes
The whole script is about 170 lines, and the date logic is plain JavaScript you can test in Node.
1. The sheet
Create a sheet named Tracker with these headers in row 1:
| A | B | C | D | E | F |
|---|---|---|---|---|---|
| Item | Due date | Remind days before | Status | Last notified |
Example rows:
| Item | Due date | Remind days before | Status | Last notified | |
|---|---|---|---|---|---|
| Domain renewal | 2026-12-09 | you@example.com | 30,7,1 | ||
| Insurance | 2027-01-15 | you@example.com |
Rules the script follows:
- Due date: a real date cell (or text like
2026-12-09). - Remind days before: a list such as
30,7,1. Leave it empty to use the default[30, 7, 1]. - Status:
Done,Renewed,CancelledorPausedstops reminders. - Last notified: the script writes here. Do not type in it.
Open Extensions > Apps Script so the script is bound to this spreadsheet, delete the sample code, and paste the code below.
2. The date logic
The one decision that keeps this reliable: compare dates as yyyy-MM-dd strings, in the spreadsheet's time zone, and do day arithmetic with UTC maths on those strings. There is no new Date() comparison, no getTime() difference across a daylight-saving change, and no "why did it fire a day early" bug.
This first block is plain JavaScript with no Apps Script services. That makes it testable anywhere.
/** * @OnlyCurrentDoc * * Email reminders from a Google Sheet. * Sheet "Tracker", headers in row 1: * A Item | B Due date | C Email | D Remind days before | E Status | F Last notified */ const SHEET_NAME = 'Tracker'; const RUN_HOUR = 8; // the trigger fires between 8:00 and 9:00 const DEFAULT_LEADS = [30, 7, 1]; // used when column D is empty const COL = { ITEM: 0, DUE: 1, EMAIL: 2, LEADS: 3, STATUS: 4, SENT: 5 }; // 0-based const CLOSED = ['done', 'renewed', 'cancelled', 'paused']; /* ---------- time zone and date helpers (no Apps Script services) ---------- */ function isIsoDate_(s) { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s); if (!m) return false; const d = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3])); return d.getUTCFullYear() === +m[1] && d.getUTCMonth() === +m[2] - 1 && d.getUTCDate() === +m[3]; } // Whole days from isoA to isoB. Pure UTC maths on yyyy-MM-dd strings, // so daylight saving can never shift the answer by a day. function daysBetween_(isoA, isoB) { const a = isoA.split('-'), b = isoB.split('-'); const ta = Date.UTC(+a[0], +a[1] - 1, +a[2]); const tb = Date.UTC(+b[0], +b[1] - 1, +b[2]); return Math.round((tb - ta) / 86400000); } // "30, 7 1" -> [30, 7, 1] (unique, largest first, junk ignored) function parseLeads_(value) { const seen = {}; const out = []; String(value === undefined || value === null ? '' : value).split(/[,;\s]+/).forEach(function (p) { if (!/^\d+$/.test(p)) return; const n = parseInt(p, 10); if (n <= 3650 && !seen[n]) { seen[n] = true; out.push(n); } }); return out.sort(function (x, y) { return y - x; }); } // "7@2026-12-09" -> {lead: 7, due: '2026-12-09'}, or null function parseMarker_(value) { const m = /^(\d+)@(\d{4}-\d{2}-\d{2})$/.exec(String(value || '').trim()); return m ? { lead: parseInt(m[1], 10), due: m[2] } : null; } /** * Should this row get an email today? Returns the lead time that applies * (30, 7 or 1) or null. * * We take the TIGHTEST lead already crossed. If the script missed a few days, * or you add a row late, you get exactly one catch-up email, never a burst. * The marker remembers "lead@due", so a changed due date starts fresh. */ function decide_(dueIso, leads, todayIso, marker) { if (!isIsoDate_(dueIso) || !leads.length) return null; const days = daysBetween_(todayIso, dueIso); if (days < 0) return null; // overdue: not handled in this tutorial let target = null; leads.forEach(function (lead) { if (days <= lead) target = lead; }); // leads are sorted high -> low if (target === null) return null; // not within any window yet if (marker && marker.due === dueIso && marker.lead <= target) return null; // already sent return target; } How decide_ works:
- Suppose the lead times are
30,7,1and the due date is 9 December. - On 9 November (30 days left) the 30-day window opens and you get one email. The script writes
30@2026-12-09in column F. - On 2 December (7 days left) you get one more and the marker becomes
7@2026-12-09. On 8 December you get the last,1@2026-12-09. - If the trigger was off for a week, or you add a row late, the script sends one catch-up email for the tightest window already passed. It never sends three at once.
- If someone changes the due date, the marker's date no longer matches, so reminders restart.
3. Reading the sheet and sending the mail
/* ---------- Apps Script side ---------- */ // getSpreadsheetTimeZone() is documented to return a string, but in my own // test sheet it did not give a usable value, and formatDate() then threw // "Invalid argument: timeZone". So: spreadsheet -> script -> UTC. function getTz_() { let tz = ''; try { tz = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone(); } catch (e) {} if (!tz || typeof tz !== 'string') { try { tz = Session.getScriptTimeZone(); } catch (e) {} } return (tz && typeof tz === 'string') ? tz : 'Etc/UTC'; } // A date cell comes back as a Date at midnight in the SPREADSHEET's zone. // Format it in that same zone to get the date the user typed. function cellToIso_(value, tz) { if (Object.prototype.toString.call(value) === '[object Date]' && !isNaN(value.getTime())) { return Utilities.formatDate(value, tz, 'yyyy-MM-dd'); } const s = String(value || '').trim(); return isIsoDate_(s) ? s : ''; } function collect_(todayIso, tz) { const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME); const values = sheet.getDataRange().getValues(); const byEmail = {}; for (let i = 1; i < values.length; i++) { const row = values[i]; const email = String(row[COL.EMAIL] || '').trim().toLowerCase(); if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) continue; if (CLOSED.indexOf(String(row[COL.STATUS] || '').trim().toLowerCase()) !== -1) continue; const due = cellToIso_(row[COL.DUE], tz); const leads = parseLeads_(row[COL.LEADS]); const lead = decide_(due, leads.length ? leads : DEFAULT_LEADS, todayIso, parseMarker_(row[COL.SENT])); if (lead === null) continue; (byEmail[email] = byEmail[email] || []).push({ sheetRow: i + 1, item: String(row[COL.ITEM] || '(no name)'), due: due, lead: lead, days: daysBetween_(todayIso, due) }); } return { sheet: sheet, byEmail: byEmail }; } function describe_(days) { return days === 0 ? 'today' : days === 1 ? 'tomorrow' : 'in ' + days + ' days'; } function run_(dryRun) { const lock = LockService.getScriptLock(); if (!lock.tryLock(30000)) return; try { const tz = getTz_(); const todayIso = Utilities.formatDate(new Date(), tz, 'yyyy-MM-dd'); const found = collect_(todayIso, tz); let quota = MailApp.getRemainingDailyQuota(); Object.keys(found.byEmail).forEach(function (email) { const items = found.byEmail[email].sort(function (a, b) { return a.days - b.days; }); const lines = items.map(function (it) { return '- ' + it.item + ': due ' + it.due + ' (' + describe_(it.days) + ')'; }); const subject = items.length === 1 ? items[0].item + ' is due ' + describe_(items[0].days) : items.length + ' items are coming due'; const body = 'Reminder:\n\n' + lines.join('\n') + '\n\nSet Status to "Done" or change the due date when it is handled.'; if (dryRun) { Logger.log('[dry run] to ' + email + ' | ' + subject + '\n' + body); return; } if (quota < 1) { Logger.log('Mail quota used up; ' + email + ' will be retried tomorrow.'); return; } try { MailApp.sendEmail(email, subject, body); // one email per person per day quota--; // Mark rows ONLY after the send worked, so a failure is retried tomorrow. items.forEach(function (it) { found.sheet.getRange(it.sheetRow, COL.SENT + 1).setValue(it.lead + '@' + it.due); }); } catch (err) { Logger.log('Could not email ' + email + ': ' + err); } }); } finally { lock.releaseLock(); } } A few details worth copying into your own scripts:
- Mark rows only after the send worked. If
sendEmailthrows (quota, bad address), the row stays unmarked and is retried on the next run. - One email per person. Everything due for the same address goes in a single message, sorted by urgency.
- A lock stops two runs (for example you clicking Run while the trigger fires) from sending twice.
- Date cells are detected with
Object.prototype.toString, and anything that is not a valid date or ayyyy-MM-ddstring is skipped instead of crashing the whole run.
The time zone pitfall
Look at getTz_(). getSpreadsheetTimeZone() is documented to return a string, but in one of my own spreadsheets the call made Utilities.formatDate fail with:
Exception: Invalid argument: timeZone. Should be of type: String So the script falls back from the spreadsheet's zone to the script's zone to Etc/UTC. Set the real one explicitly under File > Settings (General tab, Time zone) so the fallback never matters.
Why this matters: a date cell is stored as midnight in the spreadsheet's zone. For a spreadsheet set to Asia/Jerusalem, the cell "9 December" is 2026-12-08T22:00:00Z. Format it in UTC and you get 8 December, one day early. Format "today" in a different zone than the cells and you get the same off-by-one for the first or last hours of the day. Using the same zone for both, as above, avoids it. The test file at the end checks both cases.
4. Entry points and the daily trigger
/** Run this from the editor first: logs what WOULD be sent, sends nothing. */ function previewReminders() { run_(true); } /** This is what the daily trigger runs. */ function sendDueReminders() { run_(false); } /** Run once from the editor: replaces any old trigger with one daily trigger. */ function installDailyTrigger() { ScriptApp.getProjectTriggers().forEach(function (t) { if (t.getHandlerFunction() === 'sendDueReminders') ScriptApp.deleteTrigger(t); }); ScriptApp.newTrigger('sendDueReminders') .timeBased() .everyDays(1) .atHour(RUN_HOUR) .inTimezone(getTz_()) .create(); } Three functions you will run from the editor, in this order:
-
previewReminderslogs what would be sent and sends nothing. Check the output under Executions. -
sendDueReminderssends for real (this is also what the trigger will call). -
installDailyTriggercreates one trigger that fires every day.
Trigger timing: Google picks a time inside the hour you ask for. A trigger at hour 8 runs between 8:00 and 9:00 in the zone you pass to inTimezone (ClockTriggerBuilder and installable triggers). The script deletes its old trigger first, so running installDailyTrigger twice does not give you double emails.
If a trigger run fails, Google emails you a failure summary with a link to the executions log (installable triggers, "Errors in triggers").
5. Authorizing the script (including the scary screen)
The first time you run a function, Apps Script asks for permission:
- Click Run on
previewReminders, then Review permissions. - Pick your Google account.
- If you see "Google hasn't verified this app", that is expected for a script you wrote yourself. Click Advanced, then Go to (your project name) (unsafe), then Allow.
- Run the function again.
Why you see that screen: Google shows it for scripts that use sensitive scopes and have not gone through OAuth verification. According to Google's OAuth client verification page, the unverified flow also applies when the publisher is a Gmail account, including for yourself. It does not apply to Google Workspace users in the same domain as the publisher. Only authorize scripts whose code you can read. Here that is the code above.
What the script asks for:
- Your spreadsheets: the
@OnlyCurrentDoccomment on top limits this to the current file, according to Source:https://dev.to/orbitnudge/send-email-reminders-from-a-google-sheet-with-apps-script-no-servers-31l4
