function Intialize() {
return;
}
function Install() {
ScriptApp.newTrigger("purgeGmail")
.timeBased().everyMinutes(10).create();
}
function Uninstall() {
var triggers = ScriptApp.getScriptTriggers();
for (var i=0; i<triggers.length; i++) {
ScriptApp.deleteTrigger(triggers[i]);
}
}
function purgeGmail() {
var search = "to:[email protected]";
var threads = GmailApp.search(search, 0, 100);
for (var i=0; i<threads.length; i++) {
var thread = threads[i];
thread.moveToTrash();
}
}
- Go to https://script.google.com and create a new script
- Copy the above to the script input
- Click the save icon
- Click the "Run" menu
- Click the "Install" submenu entry
- Wait a few days, it will delete 100 messages each 10 minutes