Google Scripting

Using google now to dictate tasks and have them emailed, then programmatically converted into tasks.

UPDATE 20170624:

Google has broken the method for stripping HTML and getting text out of emails, but they have replaced it with a more powerful/useful

getPlainBody() method.

 

So I have successfully eliminated the function calls to strip HTML/XML from email in the main_taskconverter function.

var taskNote = getTextFromHtml((thread.getMessages()[0]).getPlainBody()).substring(0,1000);

END UPDATE

My dilemma is that I am a big fan of task lists.  I love the calendar and task list integration in Business Calendar 2.

One of my problems is that I often have really good thoughts while I’m doing something else: running, swimming or biking.  In fact I have my best ideas when I’m endurance training.  The Oatmeal clued me into this and it is very accurate for me.  Takes my mind off any suffering and lets me solve problems while my body does it’s thing.

Problem:

Google now will not create a task to add to the google task list.  I find creating tasks mildly cumbersome in BC2 since the default is to create an appointment and then I have to switch to task list and create the task.  I use todo items way more than setting appointments.

Google now is very powerful with the voice engine but it will only work with Google Keep as far as I can tell.

The workaround:

Use google now to email a task to yourself at gmail.  This is processed into a task by a script using labels.  The task is then added to your task list.  Email is marked for deletions in a few days by another scripts.

Problems:

The task is undated.  I suspect that the script can probably inject the day it was processed into the task, but cannot find this in the API settings.

Success!

After many facepalms, I figured out how to set the date on the active task to the day it is processed.  My hope for the next iterative improvement is to have the date parsed from the message body so it can be dictated.  I suspect and hope that someone has a library to do this already.

So the updated code is as follows in the main function block:

function addTask_(title, message, tasklistId) {
//var newTask = Tasks.newTask().setTitle(title);
var newTask = Tasks.newTask();
newTask.setTitle(message);
//original newTask.setTitle(title);
newTask.setNotes(title);
/*Set Date for new task to day the email was processed, as in today(this was struggle but it’s working!!!*/
var date = new Date();
var datetache = Utilities.formatDate(date, “CST”, “yyyy-MM-dd”);
datetask=datetache+”T00:00:00.00Z”;
Logger.log(datetask);
newTask.setDue(datetask);

References:

http://ittichaicham.com/wiki/Create_Google_Tasks_by_sending_email_to_Google_GMail

Automatically processing emails with scripts to delete so they don’t clutter up you email.

I have two iterations of this, a deleteMe that hangs around for 2 days for stuff like daily deals, deal alerts and blog updates that I know I won’t get back to if I don’t look at them immediatamente, and a version that deletes after 60 days for stuff like bank statement notifications and other alerts that you want to see and may need to confirm, but won’t need after two months or so.

Create time-based Gmail filters with Google Apps Script