gmail - Apps Script GmailApp archiving not working -
i have function wish tie daily time trigger in google apps script. function supposed take e-mails in inbox marked read older 14 days , archive them. here code, got here
function batcharchivea() { var batchsize = 100 // process 100 threads @ once var threads = gmailapp.search('label:"inbox" is:read older_than:14d -label:"delete me"'); (j = 0; j < threads.length; j+=batchsize) { logger.log("thread " + j); gmailapp.movethreadstoarchive(threads.slice(j, j+batchsize)); } }
i have run function manually test out few times. however, none of changes seem reflected when open inbox in gmail. still have 890+ e-mails in inbox dating 2012 (plus more under promotion, update etc. sub-labels)
thing is, execution output reported no errors, , see lot of threads being loaded , dealt in loop. however, when run script, there no threads loaded. search returns empty array , function exits.
i'm curious doing wrong. i've looked @ google developers reference gmailapp there's not can go on far debugging concerned. , presumably, since search no longer returns anything, previous runs did work... since if did archive threads older 14 search indeed no longer find them.
any ideas why i'm not seeing e-mails gone inbox when load gmail?
okay, turns out working, inbox clogged search believe grabbed maximum number of threads (which must 400-500) @ time, didn't notice difference.
i set in loop keeps running long search returns array bigger 0. meaning run through threads can (or, @ moment, until maximum execution time limit hit!). set functions run on regular basis , inbox has shrunk nothing!
Comments
Post a Comment