Using spring integration IMAP adapter, how to fetch an email which was marked “unread” manually?

若如初见. 提交于 2019-11-29 14:10:29
Artem Bilan

Looks like you need custom 'search-term-strategy'. From Spring Integration (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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!