Skip to content

Instantly share code, notes, and snippets.

@mew1033
Created April 4, 2018 16:25
Show Gist options
  • Save mew1033/cbe2df0967d042e76499b2f96a996feb to your computer and use it in GitHub Desktop.
Save mew1033/cbe2df0967d042e76499b2f96a996feb to your computer and use it in GitHub Desktop.
function markArchivedAsRead() {
var threads = GmailApp.search('label:unread -label:{inbox, Unsnoozed}');
for (var i=0; i<threads.length; i++)
{
var messages = threads[i].getMessages();
var markUnread = 1;
for (var j=0; j<messages.length; j++)
{
if (messages[j].isInInbox())
markUnread = 0;
}
if (markUnread)
threads[i].markRead();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment