Skip to content

Instantly share code, notes, and snippets.

View justinfarrelldev's full-sized avatar

Justin Farrell justinfarrelldev

View GitHub Profile
@justinfarrelldev
justinfarrelldev / gmailAutoarchive.js
Last active July 23, 2020 09:48 — forked from anonymous/gmailAutoarchive.js
Made the need for a label obsolete
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)