This file contains 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 autoDelete() { | |
console.log('Started autoDelete run.'); | |
var delayDays = 2; | |
var maxDate = new Date(); | |
maxDate.setDate(maxDate.getDate()-delayDays); | |
var label = GmailApp.getUserLabelByName("delete me"); | |
var threads = label.getThreads(); | |
if(threads.length > 0){ | |
console.log('Found ' + threads.length + ' emails marked for deletion.'); |
This file contains 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
/* | |
Original Sources: | |
- https://pixelbakery.com/recipes/gmail-automatically-delete-or-archive-emails | |
- https://benbjurstrom.com/purge-email | |
v1.1 | |
https://gist.github.com/zoidy | |
Auto-archive and delete Gmail messages based on a defined retention period. Functionality: | |
- Uses Gmail labels to apply retention rules (archive or delete) |