Extract email messages from a Lotus Notes NSF file using the Java API

I would like to use the Java API (Notes.jar), and I launch a Windows window with Lotus Notes 8.5 installed.

I don't know anything about Lotus Notes, and I just need to complete this narrow task: extracting email messages from an NSF file. I want to be able to iterate through all emails, capture metadata (From, To, Cc, etc.) Or the original MIME, if available.

I searched a little Google, but I did not find anything simple without requiring significant experience with Lotus Notes.

Some sample code to start me would be very grateful. Thanks!

UPDATE: I found an open source project that does this in Python:

http://code.google.com/p/nlconverter/

However, you are still looking for a way to do this in Java.

+4
source share
2 answers

You can write a simple Java application that receives the handle to the mail database you are interested in, then gets the standard view handle in that database and then iterates over the documents in the view. Here is an example (approximate):

import lotus.domino.*; public class sample extends NotesThread { public static void main(String argv[]) { sample mySample = new sample(); mySample.start(); } public void runNotes() { try { Session s = NotesFactory.createSession(); Database db = s.getDatabase ("Server", "pathToMailDB.nsf"); View vw = db.getView ("By Person"); // this view exists in r8 mail template; may need to change for earlier versions Document doc = vw.getFirstDocument(); while (doc != null) { System.out.println (doc.getItemValueString("Subject")); doc = vw.getNextDocument(doc); } } catch (Exception e) { e.printStackTrace(); } } } 

The getItemValueString method gets the specified field value. Other important fields of a mail document are: From, SendTo, CopyTo, BlindCopyTo, Subject, Body, and DeliveredDate. Note that Body is an element with rich text, and getItemValueString returns only the text part. DeliveredDate is a NotesDate element, and for this you will need to use the getItemValueDateTimeArray method.

+7
source

For future search engines On Linux or Windows, you can read the NSF file as plain text

Example usage with the strings command:

 strings file.nsf 

Of course, you can open the file in binary mode in the selected language and analyze the output

Note: IBM Lotus Notes or Domino is not required.

-one
source

All Articles