Posted on Sep 5, 2014 in updates | No Comments

Mailbox is awesome, but following the news that Dropbox added Condoleezza Rice to their Board of Directors (and Dropbox owns Mailbox), I found myself wanting something different.  What I loved most about Mailbox was the ability to snooze emails to some later date.  Come to find out, you can set this up with Gmail and it’s not hard at all!

It works using Google Apps Script, a JavaScript-based scripting language that you can set to add special functionality to your Google applications—including Gmail, Docs, Calendar, Contacts, and more.

The real beauty about this is that it works across all your devices and you don’t have to do anything special once it’s set up.

Here’s an easy step-by-step guide.

  1. Go to Google Drive and create a new spreadsheet.
  2. Save the spreadsheet as Gmail Snoozes for if you want to access it later.
  3. Choose Tools -> Script Editor

  4. Choose create script for Blank Project.
  5. Remove everything in the code window and paste this script:
    var MARK_UNREAD = false;
    var ADD_UNSNOOZED_LABEL = false;
    
    function do_setup() {
        GmailApp.createLabel("All Snoozes");
        GmailApp.createLabel("All Snoozes/Later");
        GmailApp.createLabel("All Snoozes/This Weekend");
        GmailApp.createLabel("All Snoozes/Tomorrow");
        GmailApp.createLabel("All Snoozes/Next Week");
        GmailApp.createLabel("All Snoozes/Next Month");
        GmailApp.createLabel("All Snoozes/Next Evening");
    }
    
    function do_move(glabel) {
        var page = glabel.getThreads(0, 100);
        if (page.length > 0) {
            GmailApp.moveThreadsToInbox(page);
            if (MARK_UNREAD) {
                GmailApp.markThreadsUnread(page);
            }
            if (ADD_UNSNOOZED_LABEL) {
                GmailApp.getUserLabelByName("unsnoozed").addToThreads(page);
            }
            glabel.removeFromThreads(page);
        }
    }
    function moveLaters() {
        do_move(GmailApp.getUserLabelByName("All Snoozes/Later"));
    }
    function moveWeekends() {
        do_move(GmailApp.getUserLabelByName("All Snoozes/This Weekend"));
    }
    function moveTomorrow() {
        do_move(GmailApp.getUserLabelByName("All Snoozes/Tomorrow"));
    }
    function moveNextWeek() {
        do_move(GmailApp.getUserLabelByName("All Snoozes/Next Week"));
    }
    function moveMonth() {
        do_move(GmailApp.getUserLabelByName("All Snoozes/Next Month"));
    }
    function moveEvenings() {
        do_move(GmailApp.getUserLabelByName("All Snoozes/Next Evening"));
    }
  6. Click the save button in the toolbar.  Give the script a name. “Gmail Snoozes” will work fine.
  7. Click the myFunction dropdown in the toolbar and choose do_setup(). This will create the labels in your Gmail account.  Run the script.
  8. You’ll be asked to connect/authenticate your Gmail account with your Docs script.
  9. After you do this, the script will execute and you can refresh Gmail (if you have it open) to see your new labels.
  10. Now you just have to associate events with the functions (moveLaters, moveNextWeek, etc).  Back in your Google Doc script, click Resources -> All Your Triggers.
  11. Click “No triggers set up. Click here to add one now.”
  12. Now you just need to create a new trigger for each snooze event. (Next Week would be a snooze event).
  13. Here’s an example of the first event.

    You can see that the moveLaters() function will run every 4 hours.  So if a Gmail is within that label, it will trigger and get moved back to the inbox.
    So the first is:
    moveLaters, Time-Driven, Hour Timer, Every 4 hours.
  14. I have the rest of mine set up as follows:
    moveNextWeek, Time-driven, Week timer, Every Monday, 8am to 9am
    moveTomorrow, Time-driven, Day timer, 8am to 9am
    moveWeekends, Time-driven, Week timer, Every Saturday, 9am to 10am
    moveMonth, Time-driven, Month timer, 1 (day of the month), 9am to 10am
    moveEvenings, Time-driven, Day timer, 6pm to 7pm
  15. Save your triggers, and your script then you can exit Google Docs. That’s it! Now all you have to do (regardless of your device) is label something you want to snooze. The script does the rest.