Dibo
Dibo

Reputation: 1189

GMail IMAP - How to get conversations (threads) list?

I am trying create similar view like in GMail. I know that GMail IMAP have extension X-GM-THRID which I can use in FETCH command, but this return me this same numbers of items and I must group them manually by thread ID. Exists any faster way to group this? I am mean, can google imap server return me list of messages grouped by thread id (like in gmail web interface)? To be more specific:

If I have this list (THREAD ID | TEXT)

I want get from server only:

Can I do that? Finally, I would have to group this by my self, but this solution is inefficient and slow (I have many messages to group)

Regards and sorry for my English.

Upvotes: 5

Views: 6293

Answers (2)

David Given
David Given

Reputation: 13701

Years old, but:

The unsatisfying answer is: you can't --- IMAP only knows about messages, not threads, so you can only get thread information by looking at all the messages and aggregating.that.

What you can do is to fetch just the UID and X-GM-THRID fields, which is fast (about 40 bytes or so per message). Then you find the first message for each thread, then use UID FETCH to pull just those. By not fetching the entire message envelope until you know which messages to fetch you save a lot of bandwidth.

Upvotes: 0

Avadhesh
Avadhesh

Reputation: 4703

The 'In-Reply-To' header of the child should have the value of the Message-Id header of the parent.

There is one another field in header 'References' which contains message ids of all its parent.

you can user either of them as per your requirement.

Upvotes: 5

Related Questions