Created
July 11, 2019 18:31
-
-
Save mitar/640d8ca15fe7c47850dac16245fc00ab to your computer and use it in GitHub Desktop.
Google Script to move e-mails to Trash
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
// You can install it at https://script.google.com/ | |
// You can configure it to run every hour to move (eventually) all e-mails under "My Triggers". There are limits | |
// which prevents it to run for more than 6 minutes. So it is normal that it timeouts. But then there are also | |
// limits on how many times per day you can run it. So just make a trigger and let it run. | |
function myFunction() { | |
while(true){ | |
Logger.log("Searching."); | |
var threads = GmailApp.search('your search query', 0, 100); | |
if (!threads.length) { | |
Logger.log("Nothing found."); | |
break; | |
} | |
Logger.log("Deleting threads."); | |
GmailApp.moveThreadsToTrash(threads); | |
Logger.log("Done."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment