Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Gmail bulk Emails manipulation

$
0
0

I am trying to deal with 600,000+ emails in inbox, my goal is to either delete or archive emails before 1/1/2021.

Doing a search and select all search results and then delete or archive as mot people know will result in the action being applied to a couple of thousands emails at a time 2,000-6,000 sometimes as high as 25,000 but it's not consistent.

I tried to use the script provided here and it worked for like 200,000 emails then I reached the "Service using too much computer time for one day." Which means That I hit the daily limit for execution, when I tried in another day I got the "Exceeded maximum execution time" error after a short while and only about 5,000 emails were processed.

The script I am using

function batchArchiveEmail() {  var batchSize = 100 // Process up to 100 threads at once  var searchSize = 500 // Limit search result to a max of 500 threads.  //Use this if you encounter the "Exceeded maximum execution time" error "funny enough it didn't help that much".  var threads = GmailApp.search('label:inbox before:2021/1/1', 0, searchSize);  for (j = 0; j < threads.length; j+=batchSize) {    GmailApp.moveThreadsToArchive(threads.slice(j, j+batchSize));  }}

In the comments user "acm" mentioned the usage of 'paged' call "Google's preferred method", but unfortunately didn't post his script.

Google Apps script doesn't have a detailed documentation about this call and all I could find was this answer, but I fail to understand how to implement/ use this call to process emails based on date since it appears to me it retrieves a list of emails starting from the most recent and I can't figure out how to use it along with a date like user "acm" did.

If anyone have another way to achieve what I want to do please do tell.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>