Created
December 5, 2013 03:32
-
-
Save imjma/7799698 to your computer and use it in GitHub Desktop.
Google Scripts for Gmail to archive inbox emails and delete old emails
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 archiveInbox() { | |
var batchSize = 100; // Process up to 100 threads at once | |
// Every thread in your Inbox that is older than two days. | |
var threads = GmailApp.search('in:inbox older_than:5d'); | |
for (var i = 0; i < threads.length; i+=batchSize) { | |
GmailApp.moveThreadsToArchive(threads.slice(i, i+batchSize)); | |
} | |
} | |
function cleanUp() { | |
var batchSize = 100; // Process up to 100 threads at once | |
var threads = GmailApp.search('older_than:1y'); | |
for (var i = 0; i < threads.length; i+=batchSize) { | |
GmailApp.moveThreadsToTrash(threads.slice(i, i+batchSize)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment