Skip to content

Instantly share code, notes, and snippets.

function gmailAutoarchive() {
var archived_threads = 0;
var delayDays = 2;
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays); // what was the date at that time?
// getUserLabels returns an array of gmail labels.
// This way we don't have to convert the array elements and will archive all user labeled threads.
var labels = GmailApp.getUserLabels()