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 GmailAutoarchive() { | |
// No need for a label | |
var delayDays = 21; // three weeks | |
var maxDate = new Date(); | |
maxDate.setDate(maxDate.getDate()-delayDays); // what was the date at that time? | |
var threads = GmailApp.search("in:inbox" + " older_than:" + delayDays.toString() + "d"); | |
for (var i = 0; i < threads.length; i++) { | |
if (threads[i].getLastMessageDate()<maxDate) |