Email yourself from a Google Sheet
blog.bettersheets.co
blog.bettersheets.co
I’ve built an app similar to this example but that takes things a bit further. It lets you send notifications to a variety of platforms and have them triggered based on conditions such as a cell containing a certain value or a date being reached etc
If you want to check it out the site is https://checksheet.app, happy to answer any questions about it.
- subject
- recipient (usually my own email address)
- day of month
- day of week
- every x days
- starting on date
- trigger today? (calculated)
A daily apps script refreshes the spreadsheet formulae (so that the TRUE/FALSE values in the last column are correct for today's date) and then sends the emails.
It took some initial setup, but it's super-easy to add new regular or one-off reminders, and obviously to remove old ones.
Note the formula in column H, which generates TRUE/FALSE. You can obviously replace this logic with whatever you want.
I set a daily 8am trigger to run this script, which sends notifications for the rows that are marked TRUE:
function sendReminderEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange('B1').setValue("");
SpreadsheetApp.flush();
sheet.getRange('B1').setValue("=TODAY()");
SpreadsheetApp.flush();
var headerrows = 3;
var numColumns = 8;
var subjectColumn = 1; // one-based, i.e. column A is 1, B is 2 etc.
var addressColumn = 2;
var conditionColumn = 8;
var startRow = 1 + headerrows; // First row of data to process
var numRows = sheet.getLastRow()-headerrows; // Number of rows to process
var dataRange = sheet.getRange(startRow, 1, numRows, numColumns);
var data = dataRange.getValues();
for (var i in data) {
var row = data[i];
if (row[conditionColumn-1]) {
var emailAddress = row[addressColumn-1];
var message = 'Reminder: ' + row[subjectColumn-1];
var subject = message;
MailApp.sendEmail(emailAddress, subject, message);
}
}
}Looks like you can get the sheet owner's email programmatically rather than hardcoding an email:
SpreadsheetApp.getActiveSpreadsheet().getOwner().getEmail();Airtable is basically Google Sheets with with all of the things a smart developer would say “why can’t they just add” and it has the most well documented API that I’ve ever seen and it’s free or close to free for small scale applications like this.
It gives a bit of peace of mind when I am on vacation, knowing that if the breaker trips I can ask someone to go and check what's up.
let's add the body
var body =
oh no. what do we do here? it's not going to be just text. It's going to be the cell in the sheet.
> We have to set a Trigger to send this email every day. but if we wanted to just send that email now we can hit "run"
> but if you can't. if it's grayed out. try saving the script.
> COMMAND + S, or hitting "save project" which looks like a floppy disc icon in the Apps Script toolbar.