Skip to content

Instantly share code, notes, and snippets.

@psankar
Created January 17, 2017 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psankar/b69a2d70bca519cd8461d96e3d7185dc to your computer and use it in GitHub Desktop.
Save psankar/b69a2d70bca519cd8461d96e3d7185dc to your computer and use it in GitHub Desktop.
GMailAutoDelete
function batchDeleteA() {
var batchSize = 100 // Process up to 100 threads at once
for (i = 0; i < 50; i++) {
var threads = GmailApp.search('label:"<LABEL_TO_DELETE>" older_than:2m');
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