mirror of
https://github.com/Luzifer/gmail-manage.git
synced 2024-11-08 15:30:10 +00:00
Initial version
This commit is contained in:
commit
5b93a0a449
3 changed files with 29 additions and 0 deletions
1
.clasp.json
Normal file
1
.clasp.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"scriptId":"1vTgZT2m51WMyO8e_3muHlzLhrrRoqiNdU9BcJn7-05aKhIpJgnKXt4VN"}
|
22
Code.js
Normal file
22
Code.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Apps Scripts may only run for ~5m so we limit the execution
|
||||
const MAX_DELETE_PER_LOOP = 1000
|
||||
|
||||
function cleanup() {
|
||||
trashByQuery("label:newsletter older_than:6m")
|
||||
}
|
||||
|
||||
function trashByQuery(query) {
|
||||
var threads = []
|
||||
var removedThreads = 0
|
||||
|
||||
do {
|
||||
threads = GmailApp.search(query)
|
||||
for (var i = 0; i < threads.length; i++) {
|
||||
var thread = threads[i]
|
||||
thread.moveToTrash()
|
||||
removedThreads++
|
||||
}
|
||||
} while (threads.length > 0 && removedThreads < MAX_DELETE_PER_LOOP)
|
||||
|
||||
Logger.log('Removed %s threads for query "%s"', removedThreads, query)
|
||||
}
|
6
appsscript.json
Normal file
6
appsscript.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"timeZone": "Europe/Paris",
|
||||
"dependencies": {
|
||||
},
|
||||
"exceptionLogging": "STACKDRIVER"
|
||||
}
|
Loading…
Reference in a new issue