Skip to content

Instantly share code, notes, and snippets.

@pepdiz
Last active July 23, 2017 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepdiz/6e0c11614f89cf314ffbb71bf8f007a8 to your computer and use it in GitHub Desktop.
Save pepdiz/6e0c11614f89cf314ffbb71bf8f007a8 to your computer and use it in GitHub Desktop.
Delete gmail emails which matches filter
function purgeMail() {
var GMAIL_LABELS = "label1, label2, label3";
var PURGE_SIZE = 0
var PURGE_DATE = "2010-01-01"
GmailApp.moveThreadsToTrash(
GmailApp.search(GMAIL_LABELS
.split(',')
.map(function (e) {return "label:" + e.trim();})
.join('|') + " size:" + PURGE_SIZE.toString() + " before:" + PURGE_DATE));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment