Created
August 25, 2023 09:30
-
-
Save cmsj/328d3ec5caf8e3f4e5ce275f13df1b66 to your computer and use it in GitHub Desktop.
Google Script thread muter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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