Skip to content

Instantly share code, notes, and snippets.

@aviskase
Forked from mew1033/mark_as_read
Last active September 9, 2019 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviskase/634dba0b10f5cd0bad3f41709ed3e41c to your computer and use it in GitHub Desktop.
Save aviskase/634dba0b10f5cd0bad3f41709ed3e41c 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