我有一个找到并改编的GMAIL脚本,名为PURGEGMAIL。对用户可用。我自己使用它,并与妻子的Google Gmail Acct共享脚本,以每晚从各种标签中清除旧电子邮件。我收到了来自Google Apps Developers的电子邮件,要求我将项目提交进行验证。 我只是一个简单的GMAIL用户,而不是开发人员。该脚本可以节省生命。
我转到此屏幕:https://console.cloud.google.com/apis/credentials/consent?project=api-project-865788727416,需要我执行OAUTH同意屏幕。 Google API有一个范围:https://mail.google.com/,我认为它需要被授权。由于我不是开发人员或GSUITE用户,因此只是普通的GMAIL用户。我怎样做才能得到他们要求的验证?他们说我可以在19/2/15放宽访问权限。 H E L P。
来源如下:
// Purge messages automatically after how many days?
//var PURGE_AFTER = "12";
function runPurge () {
purgeGmail("tmpnews","14");
purgeGmail("TmpFree","14");
purgeGmail("Tmpstores","14");
purgeGmail("sent","87");
}
/*
For details, refer http://labnol.org/?p=27605
T U T O R I A L
- - - - - - - -
Step 1. Update the values of fields GMAIL_LABEL and PURGE_AFTER above.
Step 2. Go to Run -> Initialize and authorize the script.
Step 3. Go to Run -> Install to install the script.
You can now exit this window and any email messages in Gmail folder will automatically
get purged after 'n' days. The script will run by itself everyday at 01:00 hours.
Also, you may go to Run -> Uninstall to stop the purging script anytime.
*/
function Intialize() {
return;
}
function Install() {
ScriptApp.newTrigger("runPurge")
.timeBased()
.at(new Date((new Date()).getTime() + 1000*60*2))
.create();
ScriptApp.newTrigger("runPurge")
.timeBased().everyDays(1).create();
}
function Uninstall() {
var triggers = ScriptApp.getScriptTriggers();
for (var i=0; i<triggers.length; i++) {
ScriptApp.deleteTrigger(triggers[i]);
}
}
function purgeGmail(GMAIL_LABEL,PURGE_AFTER) {
var age = new Date();
age.setDate(age.getDate() - PURGE_AFTER);
var purge = Utilities.formatDate(age, Session.getScriptTimeZone(), "yyyy-MM-dd");
var search = "label:" + GMAIL_LABEL + " before:" + purge;
try {
var threads = GmailApp.search(search, 0, 200);
if (threads.length == 200) {
ScriptApp.newTrigger("runPurge")
.timeBased()
.at(new Date((new Date()).getTime() + 1000*60*10))
.create();
}
for (var i=0; i<threads.length; i++) {
var messages = GmailApp.getMessagesForThread(threads[i]);
for (var j=0; j<messages.length; j++) {
var email = messages[j];
if (email.getDate() < age) {
email.moveToTrash();
}
}
}
} catch (e) {}
}