Skip to content

Instantly share code, notes, and snippets.

@Abdisalan
Last active August 29, 2015 14:05
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 Abdisalan/773aea79c8f5f0ce324e to your computer and use it in GitHub Desktop.
Save Abdisalan/773aea79c8f5f0ce324e to your computer and use it in GitHub Desktop.
Google Script to Clean Inbox
// 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