HomeSite Administration Page 4 - Connect Lotus Domino Server through Standalone Application with CORBA
Working with Received Mails - Administration
This article discusses Lotus Domino Notes, especially how to access to the documents stored in it with CORBA. This feature allow developers to write standalone applications that will use documents of Lotus. Moreover, the developer won't have to learn CORBA because the Lotus Domino Server has already mapped all interfaces, so we are pure users of an API. This article assumes you already have installed a Lotus Domino Server, configured the IIOP properly, and that you know how to create nsf database files.
As you know, Lotus Notes is a document management tool, but also is an email client. An email document is treated like any other document in Lotus, but they have a special fields to consult:
Posted Date
Delivered Date
From
Send To
Subject
Body
Attachments
And a lot of more information. To view this values, you only have to make the connection to your email repository. After that, you can retrieve a document collection object. With every document , using getItemValue() and getItemValueString() depends of what attribute you want, you will retrieve all information. With attachments, it's a bit different, but with the next simple example, all will be understood.
Attribute Name
Attribute
ReturnType
Subject
Subject
java.lang.String
SendTo
Send To (cc too)
java.util.Vector
PostedDate
Posted Date
java.lang.String
DeliveredDate
Delivered Date
java.lang.String
Body
Body
java.lang.String(*)
From
From
java.lang.String
*) the body of an email, it's save in a multiple RichTextItem, so you must use a StringBuffer to catching all information. Because we use this method in the theme Deleting Attachments, please refer to this section the see an example.
Also note that with dates, you can also retrieve an object of lotus.domino.DateTime with method getItemValueDateTimeArray("..."). This method will return a vector of DateTime objects, and then you will loop through the vector.
Retrieving Attachments Vector list = new Vector(); if (pDocument.hasEmbedded()) { Enumeration e = pDocument.getItems().elements(); while (e.hasMoreElements()) { Item it = (Item)e.nextElement(); if (it.getType()==Item.ATTACHMENT) { list.addElement(pDocument.getAttachment(it.getValueString())); } } return list; }
What you can see in the previous code is that, firstly you look if the document has embedded information, if it has you return an enumeration of all Items that are into the document. Then you filter all documents, only allowing attachments, and then you save it into a vector object. What you save into the vector is an EmbeddedObject.
Once fact this, with EmbeddedObject you can save it to disk using:
With extractFile method will copy the attachment where you pass with parameter.
Like all Lotus documents, you can delete fields, modify, copy, extract attachments, delete attachments. This is a very important feature, because you could filter all e-mails.