Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getThreads of Very Large Label

I have 900+ threads in a label. I would like to fetch them all to work out some metrics in a script. getThreads() seems to max at 500 threads, which aligns with what the documentation was saying:

This call will fail when the size of all threads is too large for the system to handle. Where the thread size is unknown, and potentially very large, please use the 'paged' call, and specify ranges of the threads to retrieve in each call.

So now the problem is when I do

GmailApp.getUserLabelByName("Huge Label").getThreads(501, 1000).length;

I get the message: "Argument max cannot exceed 500." Any suggestions on how to process a label with a very large thread count?

like image 986
Greg Avatar asked Mar 22 '13 14:03

Greg


1 Answers

The signature of getThreads() method is

getThreads(start, max)

So you must use

GmailApp.getUserLabelByName("Huge Label").getThreads(501, 500).length;

That will return you threads from 501 to 1000.

like image 106
Srik Avatar answered Oct 02 '22 10:10

Srik