Ruby/IMAP 从最后保存的消息 uid 开始获取消息
我正在尝试从文件夹的最后保存的消息 ID 开始获取新消息。
到目前为止,这是我的代码:
self.imap_connection.examine(folder)
imap_query = "UID SEARCH #{last_uid}:*"
messages = self.imap_connection.search(imap_query)
我从 IMAP 服务器得到的唯一响应是: 服务器接收到的 IMAP 命令出错。
那么,有谁知道 ruby imap 库获取 uids 的正确“语法”?
问候,亚历克斯
I'm trying to get new messages starting from the last saved message id of a folder.
Here's my code so far:
self.imap_connection.examine(folder)
imap_query = "UID SEARCH #{last_uid}:*"
messages = self.imap_connection.search(imap_query)
The only response I'm getting from the IMAP server is:
Error in IMAP command received by server.
So, does anyone know the correct "syntax" for the ruby imap library to get the uids ??
Regards, Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在上次获取某个 UID 之后获取所有消息对我来说很有效。
Getting all the messages after a certain last fetched UID works for me.
解决方案是通过其 uid 获取文件夹的所有邮件并保存它的 seqno(它是一个 imap 字段):
对于使用上次保存的 seqno 获取新邮件搜索:
通过上次保存的 uid 进行搜索对我来说不起作用,所以我使用了最后一个保存了 seqno ,瞧。
The solution is getting all messages of a folder by it's uid and saving it's seqno(it's an imap field):
For getting new mails search using the last saved seqno:
Searching via the last saved uid did not work for me so I used the last saved seqno and voila.