gpt4 book ai didi

java - 使用spring集成IMAP适配器,如何手动获取标记为 "unread"的电子邮件?

转载 作者:太空宇宙 更新时间:2023-11-04 14:52:34 26 4
gpt4 key购买 nike

我有一段代码,它使用 Spring Integration 的 IMAP 适配器来轮询收件箱,以读取所有未读的传入电子邮件,并且效果很好。但是,如果我打开任何电子邮件,然后在 Outlook 收件箱中将其标记为“未读”,轮询器不会获取标记的电子邮件。我可以使用 pop3 适配器来获取所有电子邮件,但会在事后删除它们,但我想将电子邮件保留在收件箱中,并且希望轮询器获取所有看不见的电子邮件。

有什么建议可以解决这个问题吗?我一直在搜索和阅读有关电子邮件适配器的文章,但没有找到任何有用的内容。

提前致谢。

最佳答案

看起来您需要自定义“搜索词策略”。来自 Spring Integration (SI) 文档:

By default, the ImapMailReceiver will search for Messages based on the default SearchTerm which is All mails that are RECENT (if supported), that are NOT ANSWERED, that are NOT DELETED, that are NOT SEEN and have not been processed by this mail receiver (enabled by the use of the custom USER flag or simply NOT FLAGGED if not supported). Since version 2.2, the SearchTerm used by the ImapMailReceiver is fully configurable via the SearchTermStrategy which you can inject via the search-term-strategy attribute. SearchTermStrategy is a simple strategy interface with a single method that allows you to create an instance of the SearchTerm that will be used by the ImapMailReceiver.

这里有一篇来自 SI 论坛的帖子,其中有有趣的 Oleg 的解释:Server does not support RECENT or USER flags

在这里您可以找到 SI DefaultSearchTermStrategy :这是一个确定您应该如何实现自己的策略的地方。我猜,你的情况是:

This email server does not support RECENT flag, but it does support USER flags which will be used to prevent duplicates during email fetch.

将 SI-mail 日志记录级别切换到 DEBUG 并查看哪个标志支持您的电子邮件服务器。

关于java - 使用spring集成IMAP适配器,如何手动获取标记为 "unread"的电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23600885/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com