4 ms·
It's built-in; it's Javascript. In the spreadsheet, the script stuff is in the "tools" menu, and it opens a new window which has a menu for "triggers". The help
by 10ren 16y ago
It's built-in; it's Javascript. In the spreadsheet, the script stuff is in the "tools" menu, and it opens a new window which has a menu for "triggers". The help is pretty excellent (reference and tutorials), but it doesn't cover Javascript's standard libraries, only google's special spreadsheet classes (BTW: there's some cool stuff in there for webserves, you can download URLs and parse XML.)
function sendEmail() {
var sheet = SpreadsheetApp.getActiveSheet();
var numRows = sheet.getLastRow() -1;// don't count first row
var selectedRow = Math.floor(Math.random() * numRows);
var dataRange = sheet.getRange(selectedRow+2, 1, 1, 2);// from A2, 1 row, 2 cols
var values = dataRange.getValues();
var date = values[0][0]; // 1st row, 1st col
var prev = values[0][1]; // 1st row, 2nd col
var message = "<HTML><BODY>"
+ '<a href="'+yourFormURLhere+'">goto form</a>'
+ '<BR>'
+ '<b>Oh snap! Remember this from '+date+'</b>'
+ '<BR>'
+ '<textarea rows="20" cols="60" name="prev">'
+ prev
+ '</textarea>'
+ '<font size=1>RemainingDailyQuota: '+ MailApp.getRemainingDailyQuota() +'<font>'
+ "</HTML></BODY>"
;
MailApp.sendEmail( yourAddressHere, "How did your day go?",
"", {htmlBody: message});
}
You get the yourFormURLhere from the form editor. The daily quota is 500 emails.
Protip: It turns out 8pm is not a good time for the trigger to send it, for you to record the day's events, if you keep odd hours like me and get up at 9pm sometimes...
EDIT the http://OhLife.com http://OhLife.com selection of the previous entry is more useful: they first choose whether it will be "one month ago" or "one week ago" etc, then work out that date, and then get the entry from that date (or I guess the next one if blank). It might turn out that for a particular person that always being reminded of "this time last week" is a very effective context (or some mix of them). Bonus: it's trivial to then describe the entry with that string, which is much more natural than some timedate format.