Skip to content

Instantly share code, notes, and snippets.

@lucagrulla
Last active March 29, 2020 11:09
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 lucagrulla/5ae4383fc170ca6cea4b625833170e52 to your computer and use it in GitHub Desktop.
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
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