Thursday, November 14, 2013

Open mail database of the session user in Java

In many Notes/Domino Applications you have to work with the mail file of the user. In Lotus script it is very easy to open the mail file of the session user.

Dim mailDB As New NotesDatabase( "", "" )
Call mailDB.OpenMail

Unfortunately the OpenMail method is not available in Java. As a workaround you can get the mail database of the session user from the DBDirectory.
Database mailDB = ses.getDbDirectory(null).openMailDatabase();

ses should be a valid Notes Session Object.


  1. public Database org.openntf.domino.Database.getMail(); returns the mail database for the current user from any Database handle.

    public void org.openntf.domino.Database.openMail(); converts any existing Database handle to an encapsulation of the current user's mail database. (Matching the Lotusscript behavior exactly.)

    1. Thanks for implementing this methods in the openntf version of the api. Can you tell me whether the openntf api is compatible to other Domino Apis. For example i create a new document in the mailDB and fill this document with the java API and then i want to open this document in the UI with NotesUIWorkspace ws = new NotesUIWorkspace(); ws.openDocument(true, new NotesDocumentData(mail)); Is this possible with the openntf Domino API?

  2. Ralf, I can't say that I've tried this, but I would expect it to work. The UI and associated data classes that IBM made use identifiable meta data for the backend API. I use the API from native Eclipse all the time.

    If you were to try it, and found problems, I think the team would take those on as bugs and address them as quickly as possible. (We've fixed most reproducable bugs within 48 hours over the history of the project.)