GMail TODO Script

After reading GMail Snooze with Apps Script I thought "Gosh, that's almost what I need to make GMail my go-to TODO list platform." Well, I finally sat down and closed the gap.

var MARK_UNREAD = true;
var MARK_IMPORTANT = true;
var ADD_TODO_LABEL = true;
var TIMEZONE = "EST";

function setup() {
  if (ADD_TODO_LABEL) {
    GmailApp.createLabel("TODO");
  }
}

function reviveTODOs() {
  var todayString = Utilities.formatDate(new Date(),
     TIMEZONE, "yyyy/MM/dd");
  var todaysLabel = 
     GmailApp.getUserLabelByName(todayString);  
  var page = null;

  // Get threads in "pages" of 100 at a time
  while(todaysLabel 
      && (!page || page.length == 100)) {
    page = todaysLabel.getThreads(0, 100);

    if (page.length > 0) {
      GmailApp.moveThreadsToInbox(page);
      
      if (MARK_UNREAD) {
        GmailApp.markThreadsUnread(page);
      }

      if (MARK_IMPORTANT) {
        GmailApp.markThreadsImportant(page);
      }
      
      if (ADD_TODO_LABEL) {
        GmailApp.getUserLabelByName("TODO")
          .addToThreads(page);
      }          
    }     
  }
}

Instead of using "Snooze x Days" labels, I use date labels like "2011/08/11" to remind myself to follow up on bills, respond to emails, etc. With this modified version of Corey Goldfeder's script, I don't have to remember to check those labels, they just pop back into my inbox automatically. I had a little problem with the markThreadsImportant call not seeming to work. Don't know what's up with that. But otherwise, it has performed well so far in testing.

Update: Be sure to set the timezone that the script will run in and the timezone used to format date labels to the same timezone. See Using Time-Driven Triggers.

Like this script? Have your own variation? Please share!

RVA GTUG - August 2011 Meeting

I'm thrilled to announce that on Thursday the Richmond, VA Google Technology User Group met for the first time. It was fantastic seeing familiar faces and also meeting some other Google enthusiasts for the first time. This is my first experience as a community organizer, so I'm excited to see how things will develop from here. We have good people who believe in the group and I'm confident we'll continue strong. Thank you to all of our members!

Special thanks to Genworth Financial for supporting the local Google developer community by letting us meet in their offices here in Richmond. If you or your organization would like to support this community, please contact me through my Google Profile or the RVA GTUG Google Group forum.

Anyone interested in membership in the RVA GTUG, please join the Google Group and introduce yourself. If you are interested in developing with Google technologies but aren't local to Richmond, VA, you can find over 260 other active and incubating GTUG chapters at gtugs.org.