Last active
March 29, 2020 11:09
-
-
Save lucagrulla/5ae4383fc170ca6cea4b625833170e52 to your computer and use it in GitHub Desktop.
Automatically archive email threads with a given label after a certain number of days - https://script.google.com/home
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
function auto_archive_mails() { | |
var filter = "label:inbox and {label:blah label:foo} older_than:3d" | |
var threads = GmailApp.search(filter); | |
console.log("found:", threads.length, " threads"); | |
threads.forEach(function(t) { | |
console.log("archived:", t.getFirstMessageSubject(), t.getLastMessageDate()); | |
t.moveToArchive(); | |
}) | |
console.log("finished."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment