Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Este script mantiene limpia mi bandeja de entrada, archivando correos antiguos
- */
- function gmailAutoArchive() {
- gmailAutoarchiveHelper("Informes",3);
- gmailAutoarchiveHelper("Sistemas",3);
- gmailAutoarchiveHelper("Diseños",3);
- gmailAutoarchiveHelper("inbox",7);
- }
- function gmailAutoarchiveHelper(queryStr, numDays) {
- Logger.log('Running archiver on label %s for numDays: %s',queryStr, numDays);
- var query = "label:"+ queryStr + " AND label:inbox AND -is:starred AND older_than:" + numDays +"d";
- var threads = GmailApp.search(query,0, 250).filter(function(thread) {
- // Only return if the thread does not have any unread messages.
- return (!thread.isUnread());
- // return (thread.isInInbox() && !thread.isUnread() && !thread.isImportant());
- });
- if(threads.length!=0){
- Logger.log('Found %s email threads belonging to %s to be archived', threads.length, queryStr);
- while (threads.length) {
- var this_batch_size = Math.min(threads.length, 250);
- var this_batch = threads.splice(0, this_batch_size);
- GmailApp.moveThreadsToArchive(this_batch);
- }
- }
- }
Add Comment
Please, Sign In to add comment