GMail IMAP - How to get a list of chains (threads)?

I am trying to create a similar view, for example, in GMail. I know that GMail IMAPs have an X-GM-THRID extension that I can use in the FETCH command, but that will return the same number of elements to me, and I have to group them manually by thread ID. Is there any faster way to group this? I mean, maybe the google imap server returns me a list of messages grouped by thread id (for example, in the gmail web interface)? To be more specific:

If I have this list (THREAD ID | TEXT)

  • 12345 hello
  • 12345 hello
  • 12345 "What?"
  • 67890 "are you there?"
  • 67890 "no, I'm not"

I want to get only from the server:

  • 12345 hello
  • 67890 "are you there?"

Can I do it? Finally, I would have to group this myself, but this solution is inefficient and slow (I have a lot of messages to group)

Regards and sorry for my English.

+4
source share
2 answers

The In-Reply-To header for the child must be set to the parent's Message-Id header value.

In the heading "Links" there is another field containing the message identifiers of all its parent elements.

You can use any of them according to your requirements.

+4
source

Years, but:

Unsatisfactory answer: you cannot --- IMAP knows only messages, not threads, so you can get information about threads by looking at all messages and aggregating them. it

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

0
source

All Articles