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 = "before:2018/08/24";
var search = "is:unread before:2018/10/12";
var threads = GmailApp.search(search, 0, 100);
for (var i=0; i<threads.length; i++) {
var thread = threads[i];
thread.moveToTrash();
}
}
function test(){
var search = "category:updates";
var threads = GmailApp.search(search, 0, 100);
for (var i=0; i<threads.length; i++) {
var thread = threads[i];
thread.moveToTrash();
}
}
- 运行环境 script.google.com
- 注意,时间间隔只能大于10min,否则的话会不执行