World changes day by day!

Saturday, July 30, 2011

Gmail Introduced Snooze of email with Apps Script

5 comments
With Gmail you can Snooze you mail like you did with alarms in clocks or phones. With Easy to use Apps Script Gmail had made it all possible. This allow user to set one or emails to get Snooze i.e appear after the particular no of days (usually 7 or less). See how we can do it.

Follow the Steps
  • Sign in with Google and go to http://docs.google.com/ and  create new Spreadsheet.
  • In the Tools menu click on Script editor...

  • Now remove My function, empty the Text Field and Paste the Code Shown below and save it with a proper name.
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; ++i) {
    GmailApp.createLabel(getLabelName(i));
  }
  if (ADD_UNSNOOZED_LABEL) {
    GmailApp.createLabel("Unsnoozed");
  }
}

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
          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);
      }  
    }
  }


  • After saving Click on Drop-down menu   'Select a function to run'  and click on setup.

  • Now click on the Run menu -> Setup or Just click the blue button closed saved one. You will asked to Authorize, so grant permission to give access to the code.


  • After Granting Permission we Will have different 7 snooze labels in Gmail each for a day. Next is to Click on  "Triggers" menu and choose "current script's triggers" and Create a new trigger with choosing the "moveSnoozes" function, a "time-driven" event, "day timer," and then "midnight to 1am." in respective Drop-down Menu. Save it.
  • Run the Function again and we have it. Just Go to Gmail and check out the Snooze Labels.
  • Now Apply Snooze label with label section or move to section to your emails as per your Choice.
Watch Video Demo

    5 comments :

    1. wow! That's very interesting and useful feature.
      Now, it is easily possible to keep importan email which need attention to be paid in fiture and not now. Cool great....thanx to gmailwow! That's very interesting and useful feature.
      Now, it is easily possible to keep importan email which need attention to be paid in fiture and not now. Cool great....thanx to gmail

      ReplyDelete
    2. will any one want to pay attention to an email later? i don't

      ReplyDelete
    3. That great........that it didn't influence you by the way a business personal may get sufficient help from it.

      ReplyDelete

    Leave Your comments