Skip to content

Instantly share code, notes, and snippets.

@cmsj
Created March 28, 2022 09:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cmsj/79d469e490b332881635d2d088ed8e54 to your computer and use it in GitHub Desktop.
gmail mute that actually mutes
// Enforce thread muting
// When you mute a thread in Gmail, it adds a "Muted" label
// Unfortunately, it doesn't really completely mute the thread - e.g. emails added to the thread will still be marked as unread and show up against folder counts
//
// This script will ensure that all emails appearing on muted threads, will be marked read, and archived.
//
// By default it will only look for emails that are less than 3 days old, to limit the size of the query results. You can adjust that if you want to
var age_max="3d"
function enforceMutes() {
var threads = GmailApp.search("label:Muted is:unread " + " newer_than:" + age_max);
for (var thread_key in threads) {
var thread = threads[thread_key];
Logger.log(" Archiving: " + thread.getFirstMessageSubject());
thread.markRead();
thread.moveToArchive();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment