I have many X-GM-THRIDs for which I want to retreive the list of uids for those threads.
https://developers.google.com/gmail/imap_extensions describes how to find these for a single X-GM-THRID. However, it would be nice if I could make one request for all of the X-GM-THRIDs that I want the data for. When I try this, I only get error codes.
Does anyone know if this is possible?
I'm using python and doing something like:
res, ids = imap_conn.uid('search', 'X-GM-THRID', thread_id)
# this works fine.
But I'd like to do something like:
res, ids = imap_conn.uid('search', 'X-GM-THRID', [thread_id1, thread_id2])
UPDATE:
after @max's answer, I'm now doing something like this:
res, ids = imap_conn.uid(
'search', None,
'(OR (OR (X-GM-THRID 123) X-GM-THRID 456) X-GM-THRID 789)')
# 123, 456, 789 are fake gmail thread ids
I'm not sure exactly what or how gmail limits search length - I think it's probably number of characters rather than number of 'OR's in the query. I can get away with about 9 before gmail starts returning errors.
You would need to add "or" qualifiers and then build an extended search query. See RFC 3501 for search format.