2

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();
}
Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
Mohan
  • 221
  • 1
  • 21

1 Answers1

3

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.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • hi ..please share some references for MIME..or some website where i can get the necessary info on MIME..thanks for the reply.. – Mohan Jan 30 '14 at 11:38
  • There is no better reference than the RFCs: http://www.ietf.org/rfc/rfc2045.txt http://www.ietf.org/rfc/rfc2046.txt http://www.faqs.org/rfcs/rfc2387.html – Richard Schwartz Jan 30 '14 at 14:53
  • Also, my best advice is to manually construct an email message that looks the way you want it to, using Notes or any other email client that you want. Send that email to an account that gives you the option to look at the original MIME. (Notes can do that, but only if the sender and recipient options are set up so that the message is sent and delivered in MIME format. I often just send to gmail.) Examine the structure of the MIME, seeing how the headers and separators form a parent-child tree, and use the NotesMIMEEntity class methods to reconstruct that tree. – Richard Schwartz Jan 30 '14 at 15:26