简体   繁体   English

如何使用 Spring 集成访问以前阅读过的电子邮件?

[英]How to reach previously read emails by using Spring Integration?

I am developing a dynamic and multiple IMAP channel listener application.我正在开发一个动态的多 IMAP 通道侦听器应用程序。 For the purpose of effectiveness, I am not downloading the attachments inside mails, just getting the texts inside them.为了效率起见,我不下载邮件里面的附件,只获取里面的正文。 Also I am developing an endpoint to access that previously arrived mails and download & return that attachment in order not to download every attachment.此外,我正在开发一个端点来访问以前到达的邮件并下载并返回该附件,以免下载每个附件。 So basically I am trying to download attachments only if there is a demand.所以基本上我只是在有需求时才尝试下载附件。

I am using ImapIdleChannelAdapter to listen mails inside integration flow.我正在使用 ImapIdleChannelAdapter 来收听集成流程中的邮件。 Here is my flow,这是我的流程,

public ImapIdleChannelAdapter mailAdapter(ImapMailReceiver receiver) {
        ImapIdleChannelAdapter imapAdapter = new ImapIdleChannelAdapter(receiver);
        imapAdapter.setAutoStartup(true);
        return imapAdapter;
    }
public IntegrationFlow createMailFlow(GmailRecieverRequirements requirements, String clientID) {
        return IntegrationFlow.from(
                mailAdapter(gmailMailReceiver(requirements)))
                .handle(getMailHandler())
                .get();
    }

My question is, how can I access those previously read mails in different time?我的问题是,我怎样才能在不同的时间访问那些以前阅读过的邮件? I know Java Mail has Folder - UID structure to access mails via UIDs.我知道 Java 邮件具有文件夹 - UID 结构,可通过 UID 访问邮件。 Here is the link .这是链接 However, I do not want to use javaMail inside my flow to save the UID.但是,我不想在流程中使用 javaMail 来保存 UID。 Is there any chance that I could reach UID of the mail inside the flow by Spring Integration?我是否有机会通过 Spring 集成获得流程内邮件的 UID? I am open to any other solution.我愿意接受任何其他解决方案。

Thanks in advance提前致谢

This is indeed low-level mail API functionality.这确实是低级邮件 API 的功能。 Not sure what you mean with your do not want to use javaMail inside my flow , but we only can do that on demand fetching if we know the folder and message UID and with that respective API of the IMAPFolder :不确定你do not want to use javaMail inside my flow是什么意思,但如果我们知道文件夹和消息 UID 以及 IMAPFolder 的相应IMAPFolder ,我们只能按需获取:

/**
 * Get the Message corresponding to the given UID. If no such 
 * message exists, <code>null</code> is returned.
 *
 * @param uid   UID for the desired message
 * @return      the Message object. <code>null</code> is returned
 *          if no message corresponding to this UID is obtained.
 * @exception   MessagingException for failures
 */
public Message getMessageByUID(long uid) throws MessagingException;

The ImapIdleChannelAdapter can produce raw jakarta.mail.Message to let you to obtain its UID via UIDFolder.getUID(Message message) API. ImapIdleChannelAdapter可以生成原始的jakarta.mail.Message以让您通过UIDFolder.getUID(Message message) API 获取其 UID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Spring集成从imap读取电子邮件不起作用 - Read emails from imap using Spring integration is not working 如何在 Spring Integration 中轮询时根据主题过滤电子邮件 - How to filter emails based on subject while polling in Spring Integration Spring Integration:如何读取队列中未使用的消息? - Spring Integration: How to read the unconsumed messages in the queue? 如何使用spring批量发送多封电子邮件 - How to send multiple emails using spring batch 对于使用弹簧集成的 GET Rest api 调用,如何读取用户定义的标题? - for GET Rest api call using spring-integration, how to read user defined headers? 使用 Spring Integration 通过电子邮件读取文件和发送内容 - Read file and send contents via Email using Spring Integration 在Spring应用程序中,如何处理(或阻止)在集成测试期间发送电子邮件? - How do you handle (or block) the sending of emails during integration testing within a Spring application? Spring Boot集成测试无法访问application.properties文件 - Spring Boot integration tests cannot reach application.properties file 如何使用Spring Integration选择/插入 - How to select/insert using Spring Integration 如何使用Spring Integration实现MQTT服务器? - How to implement MQTT server using Spring Integration?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM