Skip to content

Instantly share code, notes, and snippets.

@esseti
Created October 10, 2013 11:34
Show Gist options
  • Save esseti/6916967 to your computer and use it in GitHub Desktop.
Save esseti/6916967 to your computer and use it in GitHub Desktop.
BetterGmail experience
//This function archives all the read mail that are not in the inbox
function markArchivedAsRead() {
//i add "has:nouserlabels" beacuse i have filter that skip the emails form the inbox and place them in lables. for that case i want to keep the emails as unread.
var threads = GmailApp.search('label:unread has:nouserlabels -label:inbox');
GmailApp.markThreadsRead(threads);
};
//this funciton cleans the inbox
function cleanInbox() {
// for all the inbox mail that are not starred and are read, it archives them
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < threads.length; i++) {
var thread=threads[i];
if (!thread.hasStarredMessages() && !thread.isUnread())
GmailApp.moveThreadToArchive(threads[i]);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment