使用弹簧集成IMAP适配器,如何获取标记为“未读取”的电子邮件。手动? [英] Using spring integration IMAP adapter, how to fetch an email which was marked "unread" manually?

查看:218
本文介绍了使用弹簧集成IMAP适配器,如何获取标记为“未读取”的电子邮件。手动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段代码,它使用弹簧集成的IMAP适配器轮询收件箱来读取所有未读的传入的电子邮件,并且工作完美。但是,如果我打开任何电子邮件,然后在我的Outlook Outlook收件箱中将其标记为未读取,则该列表器不会获取标记的邮件。
我可以使用pop3适配器来获取所有的电子邮件,但删除它们的后缀,但是我想保留电子邮件到我的收件箱,我希望该轮询器获取所有看不见的电子邮件。



任何建议来处理这个问题?我一直在搜索和阅读电子邮件适配器上的文章,但没有发现任何有用的东西。



提前感谢

解决方案

看起来你需要定制的搜索术语策略。从SI文档:


默认情况下,ImapMailReceiver将根据默认的SearchTerm搜索消息,即所有邮件都是RECENT(如果支持的话) ),没有被解释,没有被删除,没有被看到,并且没有被这个邮件接收者处理(通过使用自定义USER标志启用,或者如果不支持则简单地不FLAGGED)。自版本2.2以来,ImapMailReceiver使用的SearchTerm可以通过SearchTermStrategy完全配置,您可以通过search-term-strategy属性注入。 SearchTermStrategy是一个简单的策略界面,具有单一方法,允许您创建将由ImapMailReceiver使用的SearchTerm的实例。


这里是来自SI论坛的一篇文章,其功能是Oleg的解释:服务器不支持RECENT或USER标志



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


此电子邮件服务器不支持RECENT标志,但它支持USER标志,将用于防止


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

I have a piece of code which uses spring integration's IMAP adapter to poll an inbox to read all incoming emails which are unread and that works perfectly. But if I open any email message and and then mark it as "unread" in my outlook inbox the poller doesn't fetch the marked email. I can use the pop3 adapter which fetches all the email, but deletes them afterwords, but I want to keep the emails in my inbox and I want the poller to fetch all the email which are unseen.

Any suggestions to handle this problem? I been searching and reading articles on email adapters but didn't find anything useful.

Thanks in advance.

解决方案

Looks like you need custom 'search-term-strategy'. From SI documentation:

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.

And here is a post from SI forum with funtastic Oleg's explanation: Server does not support RECENT or USER flags

And here you can find SI DefaultSearchTermStrategy: it's a place to determine how you should implement your own strategy. I guess, you case is:

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

Switch SI-mail logging level to DEBUG and take a look, which flag supports your email server.

这篇关于使用弹簧集成IMAP适配器,如何获取标记为“未读取”的电子邮件。手动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆