Last active
August 29, 2015 14:05
-
-
Save Abdisalan/773aea79c8f5f0ce324e to your computer and use it in GitHub Desktop.
Google Script to Clean Inbox
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
// Archive older emals | |
function ArchiveEmailGroup() { | |
var Size = 100 // Process up to 100 emails at once | |
var emails = GmailApp.search('label:inbox is:read older_than:14d'); // Archives 2 weeks old emails | |
for (i = 0; i < emails.length; i+=Size) { | |
GmailApp.moveThreadsToArchive(emails.slice(i, i+Size)); | |
} | |
} | |
//Mark old unread emails as read | |
function MarkReadEmailGroup() { | |
var Size = 100 | |
var emails = GmailApp.search('label:inbox is:unread older_than:31d'); // Marks 1 month old emails as read | |
for (i = 0; i < emails.length; i+=Size) { | |
GmailApp.markThreadRead(emails.slice(i, i+Size)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment