Connect Lotus Domino Server through Standalone Application with CORBA - Working with Received Mails
(Page 4 of 6 )
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 | Return Type |
| 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.
doc.getItemValueString("From")
doc.getItemValue("SendTo")
doc.getItemValueString("PostedDate")
doc.getItemValueString("DeliveredDate")
doc.getItemValueString("Subject")
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:
String Filename = oEmbeddedObject.getSource();
oEmbeddedObject.extractFile(Path + Filename);
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.
Next: Deleting Attachments >>
More Administration Articles
More By Alex Soto Bueno