Getting to inbox zero.

Many years ago when gmail was just launched in beta, my first email was the welcome email from Google. Over time I had an inbox in the thousands. In the last few years I tried to get to 0 again, but failed. Now I have learned about GTD and also a thing our two from The Behavioral Science Guys, so I decided to actually track my, uhm, progress publicly.

Gmail Inbox Chart

PS: This is done by having a Google Script write to a Google Spreadsheet that generates a public Google Spreadsheet Chart. Here is the code:

function WriteInboxCountToSpreadSheet()
{
  var ss = SpreadsheetApp.openById("TheCodePartFromTheSpreadsheetUrlHere");
  var sheet = ss.getSheets()[0];
  sheet.appendRow([Utilities.formatDate(new Date(), "Europe/Amsterdam", "yyyy-MM-dd HH:mm:ss"), MyGmailInboxCount()]);
}

2 Responses to “Getting to inbox zero.”

  1. PK says:

    Oh gosh, 5 days of not opening my email and poof: almost 300!

  2. PK says:

    Google limits the results of GmailApp.getInboxThreads(), so I had to page the counter:

    function MyGmailInboxCountAll()
    {
      var increment = 100;
      var start = 0;
      var total = 0;
      //var messages = 0;
      do
      {
        var thread = GmailApp.getInboxThreads(start, increment);
        start += increment;
        total += thread.length;
        //var messages = GmailApp.getMessagesForThreads(thread);
        //messages += messages.length;
      } while (thread.length == increment);
      //return messages;
      return total;
    }
    

    PS: I tried to change the increment, but there was little difference between 100 (19401ms) and 500 (17474ms), so to be future ready, I put it at 100. Note: 10 did cause a much bigger execution time (102175ms) on a 400+ inbox.

Leave a Reply