I’m a huge fan of keeping my inbox empty, but not very good and keeping it that way.
I’m becoming more interested in the “Quantified Self” concept i.e. you can only fix things that you can measure.
The obvious answer is to monitor what my GMail inbox looks like on a daily basis.
At first I thought this would be a horrendous script but today; whilst eating my lunch I got it to work – not only that, it’s blindingly easy. It’s using my favourite tool of the moment Google Spreadsheets and the script editor:
function myFunction() {
var doc = SpreadsheetApp.getActiveSheet()
var firstEmptyRow = doc.getLastRow() + 1;
var gmailUnread = GmailApp.getInboxUnreadCount();
var gmailInbox = GmailApp.search(‘in:inbox’).length
var gmailStarred = GmailApp.search(‘in:starred’).length
var gmailSpam = GmailApp.search(‘in:spam’).length
doc.getRange(firstEmptyRow, 1, 1, 1).setValue(new Date().getYear() +”-” + (“0” + (new Date().getMonth() +1)).slice(-2) + “-” + (“0” + new Date().getDate()).slice(-2));
doc.getRange(firstEmptyRow, 2, 1, 1).setValue(gmailUnread);
doc.getRange(firstEmptyRow, 3, 1, 1).setValue(gmailInbox);
doc.getRange(firstEmptyRow, 4, 1, 1).setValue(gmailStarred);
doc.getRange(firstEmptyRow, 5, 1, 1).setValue(gmailSpam);
}
I have scheduled this to run once a day at midnight and record a new row in the spreadsheet capturing the date, unread items, inbox count, starred count and spam items.
In an ideal world, each of these should be 0 (maybe not so at midnight) !
Next, to incorporate the stats on my personal dashboard; which is a blog post for another day!
3 replies on “InBox Zero And Quantified Self”
Hi! Interest idea, but! Error on var gmailInbox = GmailApp.search(‘in:inbox’).length – invalid character.
Try editing the code and typing in the apostrophes rather than copying them from my post.
I’ve had that problem in the past.
Great script, thanks! I had to edit the apostrophes as well. Here is the code in plain text for copy & paste: http://pastebin.com/g2RpgrhC