Skip to content

Instantly share code, notes, and snippets.

@holehan
Forked from mew1033/mark_as_read
Created March 19, 2019 14:02
Show Gist options
  • Save holehan/a6fc10a7276363a4eb4006d98f757f0d to your computer and use it in GitHub Desktop.
Save holehan/a6fc10a7276363a4eb4006d98f757f0d 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