Gmail Snooze Code - Try Out The Apps Script Feature

Many times we want to check an email but we don't have the time right now. In this case, we can “snooze” that email.
To snooze an email means to archive it for now, but to have it automatically reappear in the inbox at some specified time in the future.

With Apps Script we can extend Gmail to add this functionality and a lot more.


Here's how to do this:

The “setup” function creates a new “Snooze” label in your Gmail, along with 7 sublabels for snoozing for different lengths of time, and potentially an “Unsnoozed” label. Running this function will also prompt you to authorize the script to use Gmail.

This function makes use of the “getLabelName” helper function, which will be used by the code below.

Note: After you run the setup() function, the labels will be created in Gmail. However, you may have to refresh your Gmail window to see the labels.

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

function setup() {
  // Create the labels we’ll need for snoozing
  for (var i = 1; i <= 7; ++i) {
To move the snooze queue:

The “moveSnoozes” function moves messages one day forward in the queue, so that messages snoozed for 6 days are now snoozed for 5 days, etc. Messages in the 1-day label are moved back into the inbox, and potentially marked as unread. To make this work automatically, you’ll need to create a nightly #-Link-Snipped-# to run “moveSnoozes”.

function moveSnoozes() {
  var oldLabel, newLabel, page;
  for (var i = 1; i <= 7; ++i) {
    newLabel = oldLabel;
    oldLabel = GmailApp.getUserLabelByName(getLabelName(i));
    page = null;
    // Get threads in "pages" of 100 at a time
    while(!page || page.length == 100) {
      page = oldLabel.getThreads(0, 100);
      if (page.length > 0) {
        if (newLabel) {
          // Move the threads into "today’s" label
        } else {
          // Unless it’s time to unsnooze it
          if (MARK_UNREAD) {
          if (ADD_UNSNOOZED_LABEL) {
        // Move the threads out of "yesterday’s" label
Use 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. If you want the messages to reappear as unread, just change “MARK_UNREAD” at the top to be “true”.

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.

If you don't know how to setup a script, it's pretty simple. Create a new Google Spreadsheet, and choose "Script Editor" from the "Tools" menu. Paste in all of the code from above and 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 are done.

Try it out & post here about how it works.


    Just thinking if we can schedule our outgoing emails too. Suppose I write a mail and I want to send it at 12 pm. Can I do that? Is there something like a snooze there too?

You are reading an archived discussion.

Related Posts

servo motors or dc motors or stepper motors ??i m controlling using atmega32
hey guys. Which is the best web browser for browsing?
I want to cool a room but not with air conditioner ​
I've been using iPad for quite some now. Today, I noticed a change in the look and feel of Google's front page on iPad. The new look is simpler and...
Can access the cookies stored by website ? If yes then how ? One possible option is that behaves like a client and change its browser settings...