我需要将邮件存储到一个收集对象或数据库中,以便进行邮件处理。以下是可以显示邮件的代码,谁能告诉我如何将邮件保存到收集对象(ArrayList)或数据库中。
public void startMail(String user, String pw) {
IntegrationFlow flow = IntegrationFlows
.from(Mail.imapInboundAdapter(imapUrl(user, pw))
.javaMailProperties(p -> p
.put("mail.debug", "true")
.put("mail.imap.connectionpoolsize", "1")
.put("mail.imap.socketFactory.class", javax.net.ssl.SSLSocketFactory.class)
.put("mail.imap.socketFactory.fallback", false)
.put("mail.store.protocol", "imaps"))
.simpleContent(true)
, c -> c.poller(Pollers.fixedRate(60000)))
.handle(System.out::println)
.get();
this.flowContext.registration(flow).register();
}
不知道你要做什么和如何与一些集合,但要存储到数据库,你需要使用各自的 JdbcMessageHandler
通道适配器 .handle()
.
更多信息请参见docs。
https:/docs.spring.iospring-integrationdocscurrentreferencehtmldsl.html#java-dsl-protocol-adapters。