GMail IMAP - 如何获取对话(线程)列表?
我正在尝试创建类似 GMail 中的视图。我知道 GMail IMAP 有扩展 X-GM-THRID,我可以在 FETCH 命令中使用它,但是这个 返回给我相同数量的项目,我必须手动将它们分组 线程 ID。有没有更快的方法来分组?我很吝啬,可以谷歌吗 imap 服务器返回按线程 ID 分组的消息列表(就像在 gmail Web 界面中一样)?更具体地说:
如果我有这个列表 (THREAD ID | TEXT)
- 12345 "hello"
- 12345 "hi"
- 12345 "what's up?"
- 67890“你在吗?”
- 67890“不,我不是”
我只想从服务器获取:
- 12345“你好”
- 67890“你在吗?”
我可以这样做吗?最后,我必须自己对它进行分组,但这个解决方案效率低下且缓慢(我有很多消息要分组)
对我的英语表示问候和抱歉。
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)
- 12345 "hello"
- 12345 "hi"
- 12345 "what's up?"
- 67890 "are you there?"
- 67890 "no, I'm not"
I want get from server only:
- 12345 "hello"
- 67890 "are you there?"
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
子级的“In-Reply-To”标头应具有父级的 Message-Id 标头的值。
标头“References”中还有另一个字段,其中包含其所有父级的消息 ID。
您可以根据您的要求使用其中任何一个。
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.
多年了,但是:
令人不满意的答案是:你不能 --- IMAP 只知道消息,而不知道线程,因此你只能通过查看所有消息并聚合来获取线程信息。
您可以做的就是仅获取 UID 和 X-GM-THRID 字段,速度很快(每条消息大约 40 个字节左右)。然后,您找到每个线程的第一条消息,然后使用 UID FETCH 来提取这些消息。在知道要获取哪些消息之前不获取整个消息信封,可以节省大量带宽。
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.