Skip to content

Instantly share code, notes, and snippets.

@pooza

pooza/purgeMails.gas

Last active Feb 14, 2020
Embed
What would you like to do?
Gmail上で、bulkラベルのついた古いメールを削除。
function purgeMails () {
const days = 30
const step = 500
const labels = ['label:bulk']
const date = new Date()
date.setDate(date.getDate() - days)
labels.map(label => {
let offset = 0
let threads = GmailApp.search(label, offset, step)
while (0 < threads.length) {
threads.map(thread => {
if (thread.getLastMessageDate() < date) {
thread.moveToTrash()
}
})
offset += step
threads = GmailApp.search(label, offset, step)
}
})
}
@pooza

This comment has been minimized.

Copy link
Owner Author

@pooza pooza commented Jan 9, 2020

GASに登録し、1時間毎などで実行。

@pooza

This comment has been minimized.

Copy link
Owner Author

@pooza pooza commented Feb 14, 2020

V8対応に伴い、更新。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.