简体   繁体   中英

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

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

My question is , do i need to extend lotus.domino.AgentBase ?

If yes then what all dependencies do i require as , JAVA app is not allowing to extend it. & 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.

    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.

Then access that view and iterate through it.

You will have to switch to using notes.jar instead of 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.

May require Secure Connection(SSL), Use the following properties to connect mail server supporting POP3 protocol:

        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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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