Last active
November 14, 2020 07:28
-
-
Save riyaz/9048a5e2fc72125beb62db910987a635 to your computer and use it in GitHub Desktop.
delete mails in promotions, social, forums which are older than 1 month
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 deleteMail() { | |
var filter = "{category:promotions category:social category:forums} in:spam -in:starred -in:important older_than:5d" | |
var threads = GmailApp.search(filter, 0, 100); | |
Logger.log("Deleting " + threads.length); | |
for (var i = 0; i < threads.length; i++) { | |
Logger.log("Deleting .. " + threads[i].getFirstMessageSubject()); | |
threads[i].moveToTrash(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment