I would like to poll emails based on subject.
If we would like to poll emails which has the Subject as "Test”, the below code fetches all the emails. But we need to filter the ones with subject "Test".
How can I filter based on subject?
@Configuration
@EnableIntegration
public class PollSubjectEmail {
@Bean
public IntegrationFlow pop3MailFlow() {
return IntegrationFlows
.from(Mail.pop3InboundAdapter(“xxx.host.com", pop3Port, “username”, “password”)
.javaMailProperties(p -> p.put("mail.debug", "true")),
e -> e.autoStartup(true).poller(Pollers.fixedDelay(6000)))
.enrichHeaders(s -> s.headerExpressions(h -> h.put(MailHeaders.SUBJECT, "payload.subject")
.put(MailHeaders.FROM, "payload.from[0].toString()")))
.channel("pop3Channel").get();
}
}
I am using pop3Channel and tried by using filter. However not sure how to get to the solution.