简体   繁体   English

如何从Lotus Notes Domino服务器中获取JAVA中所有未读的电子邮件

[英]How to get all unread emails in JAVA from lotus notes domino server

I am new to Notes JAVA API and developing a utility where I require to read all unread mails from a Lotus notes id.Now when i try to use lotus.domino.Database.getAllUnreadDocuments() it gives me the following exception 我是Notes JAVA API的新手,正在开发一个实用程序,在其中我需要从Lotus Notes ID中读取所有未读邮件。现在,当我尝试使用Lotus.domino.Database.getAllUnreadDocuments()时,它给了我以下异常

NotesException: Not implemented
at lotus.domino.cso.Base.notImplemented(Unknown Source)
at lotus.domino.cso.Document.markRead(Unknown Source)
at com.email.ReadEmailRemotely.readEmails(ReadEmailRemotely.java:428)
at com.email.ReadEmailRemotely.run(ReadEmailRemotely.java:96)
at java.lang.Thread.run(Unknown Source)

My application is a plain JAVA application in eclipse using NCSO.jar 我的应用程序是使用NCSO.jar在Eclipse中使用的普通JAVA应用程序

My question is , do i need to extend lotus.domino.AgentBase ? 我的问题是, 我需要扩展Lotus.domino.AgentBase吗?

If yes then what all dependencies do i require as , JAVA app is not allowing to extend it. 如果是,那么我需要什么依赖,JAVA应用不允许扩展它。 & if no then is there any other way to get all unread mails? &如果没有,那么还有其他方法来获取所有未读邮件吗?

If the server supports IMAP or POP3, you can use JavaMail API, which is pretty easy and has a flag for unread messages. 如果服务器支持IMAP或POP3,则可以使用JavaMail API,它非常简单,并且具有未读邮件的标志。

    Properties props = System.getProperties();
    props.setProperty("mail.store.protocol", "imaps");

    try {
            Session session = Session.getDefaultInstance(props, null);
            Store store = session.getStore("imaps");
            store.connect("myserver.com", "user", "pass");

            Folder inbox = store.getFolder("Inbox");
            inbox.open(Folder.READ_ONLY);

            FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
            Message messages[] = inbox.search(ft);
     }

An easy way (assuming you are can edit the NSF) is to create a hidden view which lists only the documents you want to get back. 一种简单的方法(假设您可以编辑NSF)是创建一个隐藏视图,该视图仅列出您要取回的文档。

Then access that view and iterate through it. 然后访问该视图并对其进行遍历。

You will have to switch to using notes.jar instead of ncso.jar. 您将不得不切换到使用notes.jar而不是ncso.jar。

In order to use notes.jar and access the getAllUnreadDocuments method, you will need to install Notes and Domino 8 or above on the system where your code is running. 为了使用notes.jar并访问getAllUnreadDocuments方法,您将需要在运行代码的系统上安装Notes和Domino 8或更高版本。

May require Secure Connection(SSL), Use the following properties to connect mail server supporting POP3 protocol: 可能需要安全连接(SSL),使用以下属性连接支持POP3协议的邮件服务器:

        properties.put("mail.pop3.socketFactory.port", "POP3_PORT");
        properties.put("mail.pop3.host", "POP3_SERVER_HOST_NAME_OR_IP");
        properties.put("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        properties.put("mail.pop3.socketFactory.fallback", "false");

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM