2
votes

Hi guys i am working on sending an email in lotus notes through java.I am able to send an email.For external attachments i am constructing an rich text item.but i am not getting how to deal with inline attachments such as an image inside a mail body part. Here is the code i am using.thanks

                Document doc = null; 
            RichTextItem rti = null;
            try{
                doc = db.createDocument();
                doc.replaceItemValue(ServiceConstants.FROM,getFrom() );
                doc.replaceItemValue(ServiceConstants.FORM, getForm());
                doc.replaceItemValue(ServiceConstants.SUBJECT, getSubject());
                doc.replaceItemValue(ServiceConstants.SENDTO,asVector(getSendTo()));
                doc.replaceItemValue(ServiceConstants.COPYTO,asVector(getCopyTo()));
                doc.replaceItemValue("Principal",getFrom());
    rti = doc.createRichTextItem(ServiceConstants.BODY);
                rti.appendText(getBody());
                if ((getAttachment() != null) && (getAttachment().length > 0)) {
                    for (int i=0; i<getAttachment().length; i++)    {
                        getAttachment()[i].save(rti);
                    }
                }   
                doc.save();
                if (send) {
                    doc.send();
}
1

1 Answers

3
votes

The capabilities of the NotesRichTextItem class are fairly limited. There is a 3rd party API called MIDAS from a company called Genii Software that is considerably more powerful and may give you the capabilities that you want, however it is commercial software and it is generally used from LotusScript. I'm not even sure if Genii supports it in Java.

That said, the other approach is to use the NotesMIMEEntity class instead of the NotesRichTextItem. To do in-line images in MIME, you will need to create a multipart/mixed entity containing a multipart/related entity containing text/html and image/gif (for example, if that's the type of your images) entities, where the image entities have Content-disposition: Embedded; filename=xxx and the tags within the text/html body would use the "src=cid:xxx" format to refer to the image entities.