0
votes

I am looking for some assistance as I did a bunch of searching and saw others with similiar problems but no solution. Simply put the google apps script class/method GmailApp.search is not returning a full set of results, and it is clearly not due to a limit or anything I can see obviously like that.

Very basic usage... I have a Gmail label, lets call it "labelname" with 118 messages in it. When I search on www.gmail.com and enter "label:labelname" in the search box I get back 118 results as expected, but when I run: GmailApp.search('label:labelname'); from my script it returns only 116.

Script search syntax: threads = GmailApp.search('label:labelname');

After finding I am missing results I also added the count method to verify: Logger.log(threads.length)

Which also returns 116.

I removed my label and re-added it to all 118 and GmailApp.search still only found 116. I added my label to an additional message and tested again, now 119 on gmail.com and it went up to 117 in script result. Still missing same 2 messages.

What could it be? Their is nothing noticeable different about the 2 messages missing. Same folder, same label, same exact style message send on the same date as others.

What could cause this?

Thanks so much in advance for any suggestions!


1
Are you searching for messages or threads? For example: in Gmail you have 8 threads. 7 where you only received 1 email and 1 thread where you replied and got a reply back. In that case you have 10 messages, but 8 threads. This really matters if you have "Conversation view off" in Gmail, because you will see individual messages, but GmailApp will only look for threads and never messages. - Vytautas

1 Answers

0
votes

GmailApp.search gives threads not individual mails.

If you unset the Conversation View in Gmail settings. It will show individual mails. So in that case there will be a mismatch between the count.