Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GmailIndef() {
- var INDEF_LABEL = 'Indef';
- var RETENTION_DAYS = 356;
- var RETENTION_DATE = new Date();
- RETENTION_DATE.setDate(RETENTION_DATE.getDate() - RETENTION_DAYS);
- var threads = GmailApp.search('in:anywhere'
- + ' -(label:' + INDEF_LABEL + ')'
- + ' before:' + RETENTION_DATE.getFullYear()
- + '-' + (RETENTION_DATE.getMonth() + 1)
- + '-' + RETENTION_DATE.getDate());
- threads.forEach(function(thread) {
- GmailApp.moveThreadToTrash(thread);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement