Search code examples
lotus-notesjavaagents

How to maintain rich text format and in line images in a email send to web?


I have a view which receives emails from web, then I catch those and send them to a website. The problem is that the rich text which contains the body of the email loses its attributes (color, bold text, etc.) and images are lost or, if I use embedObject, they lost position (only are placed in the begging or end of the email).

There is a lot of information on the web but, few examples which work. Something with MIME format, convert to hmtl or xml are the options, but I cannot put them to work.

Seeing the properties of the document in the view, the MIME format converts all the email in a bunch of pieces, a lot of body ones. One of the body's have all the html code of the email, but I cannot access it. That is I think, the easiest solution, and my question. How can I access it, put in to a string and send it to the web? Anyone have any tips or other solution to it?

P.S.: In the client view the email is perfectly formatted and images in place, I cannot just put the view on the web.

The body's parts and the html one

The base of my java agent is the following code:

public void NotesMain() {
    try {
//I create a doc and use replaceItemValue to copy the other parts of the email.
    RichTextItem rich = null;
    String string = "";
    rich = (RichTextItem) doc.getFirstItem("Body");
    string = rich.getFormattedText(false, 0, 0);
    rich.appendText("string");
    }
}

This code kind of converts MIME/RichText to plane text.


Solution

  • Just readdress (change the SendTo field) and forward the existing document instead of creating a new document and copying items.

    If you don't want to alter the existing document, that's okay. You just call the Send() method without calling the Save() method.