Skip to main content

Home/ NEW SLATE (WM-CSPD)/ What is Gmail Snooze
Rob Reynolds

What is Gmail Snooze - 3 views

google gmail script programming

started by Rob Reynolds on 31 Jul 11
  • Rob Reynolds
     
    What is Gmail Snooze?
    One feature that some of us really wanted was for Gmail to let you "snooze" an email. Snoozing means archiving an email for now, but having it automatically reappear in the inbox at some specified time in the future. With Apps Script you can extend Gmail to add this functionality and a lot more yourself.



    How to set it up
    Even if you don't know how to write a script, it's pretty simple. Go to Google Docs and create a new spreadsheet, then choose "Script Editor" from the "Tools" menu. Paste in the following code:

    var MARK_UNREAD = false;
    var ADD_UNSNOOZED_LABEL = false;

    function getLabelName(i) {
    return "Snooze/Snooze " + i + " days";
    }

    function setup() {
    // Create the labels we'll need for snoozing
    GmailApp.createLabel("Snooze");
    for (var i = 1; i <= 7><= 7> 0) {
    if (newLabel) {
    // Move the threads into "today's" label
    newLabel.addToThreads(page);
    } else {
    // Unless it's time to unsnooze it
    GmailApp.moveThreadsToInbox(page);
    if (MARK_UNREAD) {
    GmailApp.markThreadsUnread(page);
    }
    if (ADD_UNSNOOZED_LABEL) {
    GmailApp.getUserLabelByName("Unsnoozed")
    .addToThreads(page);
    }
    }
    // Move the threads out of "yesterday's" label
    oldLabel.removeFromThreads(page);
    }
    }
    }
    }
    Then click the "Save" button and give it a name. In the dropdown labeled "Select a function to run," choose "setup" and click the blue run arrow to the left of it. This will ask you to authorize the script, and will create the necessary labels in your Gmail. Then go to the "Triggers" menu and choose "current script's triggers." Click the link to set up a new trigger, choosing the "moveSnoozes" function, a "time-driven" event, "day timer," and then "midnight to 1am." Click save and you're done.

    Using the Snooze Label in Gmail
    To "snooze" a thread, use Gmail's "Move To" button to move the thread into the "Snooze for X days" label and archive it. Every night, threads will move up through one day of the queue, and at the appointed number of days they will reappear in your inbox, unarchived.

    Because this is an Apps Script, you can edit the code any way you like. If you'd like different snooze times or for unsnoozed messages to get starred, you can easily change the code. And if you have an even better idea for how to use Apps Script to improve Gmail, you can post it to our Gallery (Script Editor > Share > Publish Project) to share with the world.

To Top

Start a New Topic » « Back to the NEW SLATE (WM-CSPD) group