Created
March 17, 2019 10:21
-
-
Save superbrothers/59aafd7bc6a9536cc227570230d05a48 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 autoArchive() { | |
var delayDays = 7; // 7 days before messages are moved to archive. | |
var maxDate = new Date(); | |
maxDate.setDate(maxDate.getDate() - delayDays); | |
var threads = GmailApp.search("in:inbox -is:starred") | |
threads.forEach(function (thread) { | |
if (thread.getLastMessageDate() < maxDate) { | |
thread.moveToArchive() | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment