I need to fetch all sent mail that are not deleted but not happening, but only shows total mails, recent at console in mail.debug true
<int:channel id="receiveChannel" />
<int-mail:imap-idle-channel-adapter id="customAdapter"
store-uri="imaps://[email protected]:[email protected]:993/INBOX.Sent"
channel="receiveChannel"
auto-startup="true"
should-delete-messages="false"
should-mark-messages-as-read="false"
java-mail-properties="javaMailProperties"/>
<util:properties id="javaMailProperties">
<prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imap.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">true</prop>
</util:properties>
public static void main (String[] args) throws Exception {
ApplicationContext ac = new ClassPathXmlApplicationContext("spring/gmail-imap-idle-config.xml");
DirectChannel inputChannel = ac.getBean("receiveChannel", DirectChannel.class);
inputChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) throws MessagingException {
MimeMessage mimeMessage = (MimeMessage) message.getPayload();
}
});
}
See the documentation, you need to use a custom SearchTermStrategy.
By default, the
ImapMailReceiverwill 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). The custom user flag isspring-integration-mail-adapterbut can be configured. Since version 2.2, the SearchTerm used by the ImapMailReceiver is fully configurable via theSearchTermStrategywhich you can inject via thesearch-term-strategyattribute.SearchTermStrategyis 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With