Created
December 30, 2019 14:46
-
-
Save patoroco/21bba84ab0f751ff2e34cf4e08d0cba5 to your computer and use it in GitHub Desktop.
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 main() { | |
deleteOldMessages('notifications-jenkins'); | |
deleteOldMessages('notifications-sentry'); | |
} | |
function deleteOldMessages(label_to_delete) { | |
var search = 'label:' + label_to_delete + ' -{label:Trash} older_than:6m'; | |
var threads = GmailApp.search(search, 0, 120); | |
console.log("Search: `" + search + "` (" + threads.length + " threads)"); | |
for (var i in threads) { | |
var thread = threads[i]; | |
var subject = thread.getFirstMessageSubject(); | |
thread.moveToTrash(); | |
console.log("Moving to the trash: " + subject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used in https://script.google.com