I really hate repeated tasks, so I do everything I can to minimize them. It's helpful to split up big tasks into smaller TODOs, so every week the team edits a Google Doc that has the past week's successes, past week's failures, and this week's goals. I wrote a script in Google Apps Script that converts the Google Doc to HTML and emails it to the team a couple hours and our advisors so they can track our progress. It runs on a time trigger which is good because it means everyone has to be sure their goals are finalized by the time the email goes out.
read more
//someone sending entire doc as HTML
//https://stackoverflow.com/a/43582342/2611730
//someone else sending entire doc as HTML, but uses mailchimp to get all the styles (which we don't need)
//https://gist.github.com/erickoledadevrel/11143648
//yet another, but more simple HTML one
//https://ctrlq.org/code/20009-convert-google-documents
//from https://ctrlq.org/code/20009-convert-google-documents
//note: unfortunately, not all of the bullet points show up on iPhone, so can use the default
//bullets on Google doc or could try changing them to something that looks good on Google Doc
//and shows up on iPhone. You can actually customize the individual bullets to any character, so could
//find something that works most likely: https://gsuitetips.com/tips/docs/personalise-bullet-points-and-numbers-in-google-docs/
function exportAsHTML(documentId){
var forDriveScope = DriveApp.getStorageUsed(); //needed to get Drive Scope requested
var url = "https://docs.google.com/feeds/download/documents/export/Export?id="+documentId+"&exportFormat=html";
var param = {
method : "get",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions:true,
};
var html = UrlFetchApp.fetch(url,param).getContentText();
// for some reason, google randomly started loading (or always was) the CSS with hundreds of KBs of shit CSS that doesn't
// actually do anything, but was getting so big that the emails would refuse to send. This is a line to strip all that shit out.
var html = '<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"><style type="text/css">' + html.split("ol\{")[1]
//var file = DriveApp.createFile(documentId + ".html", html);
//return file.getUrl();
return html;
}
function emailWeeklyUpdateToTeam() {
// Open the actual to do list document
var doc = DocumentApp.openByUrl('https://docs.google.com/[redacted]');
var docID = doc.getId();
// make a temporary copy of it where we will delete everything that shouldn't be included in the email
var tempDocID = DriveApp.getFileById(docID).makeCopy().getId();
var tempDoc = DocumentApp.openById(tempDocID);
// iterate through the lines, and delete everything after the second "Last Week" is seen, since that's two weeks ago
paragraphs = tempDoc.getBody().getParagraphs();
lastParagraphText = "notEmpty";
for (index in paragraphs){
paragraphText = paragraphs[index].getText();
// cut down the extra empty new lines so that it's more easily readible
// in an email
if(lastParagraphText == "" && paragraphText == "" && lastParagraphText != "Long Term Goals:"){
try{
paragraphs[index].removeFromParent();
}catch(e){}
}
if(paragraphText.indexOf("Note: Update") == 0 || paragraphText.indexOf("Long Term Goals:") == 0 || paragraphText.indexOf("(This must be the bottom-most line of the file") == 0){
try{
paragraphs[index].removeFromParent();
}catch(e){}
}
lastParagraphText = paragraphText;
}
// Logger.log(tempDoc.getBody().getText());
// save the deletions of the temp doc
tempDoc.saveAndClose();
// can prevent the email by uncommenting this return
//return;
// get an html version of the temp doc now that it has only what we want to send
var tempDocAsHTML = exportAsHTML(tempDocID)
// delete the temporary copy since we're done with it
DriveApp.getFileById(tempDocID).setTrashed(true);
MailApp.sendEmail({
to: "[redacted]",
replyTo: "[redacted]",
name: "Coursicle Team",
subject: "Coursicle Weekly Update",
htmlBody: tempDocAsHTML
});