Skip to content

Instantly share code, notes, and snippets.

@MSakamaki
MSakamaki / gmailCleanup.js
Created April 2, 2022 04:23 — forked from gabmontes/gmailCleanup.js
Google Apps script to cleanup messages from GMail.
// Inspired in http://www.johneday.com/422/time-based-gmail-filters-with-google-apps-script
// Deletes old marked conversations
function cleanUp() {
var delayDays = 5; // # of days before messages are moved to trash
var label = "Delete me"; // label to identify the messages
var maxDate = new Date(Date.now() - delayDays * 24 * 60 * 60 * 1000);
var userLabel = GmailApp.getUserLabelByName(label);
if (!userLabel) {
return;