Skip to content

Instantly share code, notes, and snippets.

@hcon94
Created October 17, 2017 10:33
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 hcon94/2f1faa2b983ce463e03368292dcb808a to your computer and use it in GitHub Desktop.
Save hcon94/2f1faa2b983ce463e03368292dcb808a to your computer and use it in GitHub Desktop.
function gmailAutoarchive() {
// Get all the threads that are labelled
var labels = GmailApp.getUserLabels();
for (var a = 0; a < labels.length; a++) {
var threads = labels[a].getThreads(0, 400);
// Archive all the labelled threads
for (var i = 0; i < threads.length; i++) {
threads[i].moveToArchive();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment