Last active
December 15, 2021 08:14
-
-
Save kazgoto/8e1109295384a2d86f71dcc310642b69 to your computer and use it in GitHub Desktop.
Gmail で特定ラベルの大量なメールを削除するバッチ関数(どっかで拾ったもの)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function batchDeleteEmail() { | |
var loopNumber = 50 | |
var batchSize = 100 // Process up to 100 threads at once | |
var searchSize = 400 // Limit search result to a max of 400 threads. Use this if you encounter the "Exceeded maximum execution time" error | |
for (i = 0; i < loopNumber; i += 1) { | |
var threads = GmailApp.search('label:XXXX', 0, searchSize); | |
for (j = 0; j < threads.length; j += batchSize) { | |
GmailApp.moveThreadsToTrash(threads.slice(j, j + batchSize)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment