4

I am trying to insert some inline image and inline attachment inside Notes document, using Rich Text format by lotus.domino package Java API, and send it.

The code of inserting is as below.

// Insertion by RichTextItem.embedObject()

RichTextItem rti = (RichTextItem) doc.getFirstItem("Body");
RichTextNavigator rtnav;
rtnav = rti.createNavigator();
rtnav.findFirstElement( .../*Somewhere inside document*/ );
rti.beginInsert(rtnav);
rti.embedObject(EmbeddedObject.EMBED_ATTACHMENT,null, "C:\\TEMP\\abc.jpg", "InlineImageOrAttachment"); // insert file which is jpg/png/pdf/doc...etc
rti.endInsert();

Right now I have got: enter image description here

What I want to have is: enter image description here

Thanks in advance.

Nozomi
  • 41
  • 1
  • 3
  • Maybe if you create the mail as MIME ? Otherwise I see little chance to create the mail in the backend.... – umeli Jun 17 '15 at 15:16
  • 1
    where will run the code? server side or client side? If I remember good the icon displayed for the attachment (say winrar icon if extension is .rar) depends on the local configuration. If code run on server where winrar is not install you will never have the winrar icon. – Emmanuel Gleizer Jun 18 '15 at 05:28
  • The code will be run in server side. In the development environment, Domino, Notes, and all type of pdf/png/rar softwares are installed. – Nozomi Jun 18 '15 at 06:30

1 Answers1

0

Here is a LotusScript function I found on the net. the same classes should be available in Java:

Function EmbedPictureIntoRichText(doc As NotesDocument,strFilePath As String)
       EmbedPictureIntoRichText = False
       Dim session As New NotesSession
       Dim db As NotesDatabase
       Dim body As NotesMIMEEntity
       Dim header As NotesMIMEHeader
       Dim child As NotesMIMEEntity
       Dim stream As NotesStream
       Dim fileFormat As String
       Dim rtitemA As NotesRichTextItem
       Dim rtitemB As NotesRichTextItem

       session.Convertmime = True
       Set db = doc.parentdatabase
       Set stream = session.CreateStream
       Call stream.Open(strFilePath)
       Set body = doc.CreateMIMEEntity("DummyRichText")
       Set header = body.CreateHeader("Content-Type")
       Call header.SetHeaderVal("multipart/mixed")
       Set child = body.CreateChildEntity()
       fileFormat = "image/jpeg"
       Call child.Setcontentfrombytes(stream, fileFormat, 1730)
       Call stream.Close()
       Call doc.save(False, False)
       Set rtitemA = New NotesRichTextItem(doc,"Photo")
       Set rtitemB = doc.GetFirstItem("DummyRichText")
       Call rtitemA.AppendRTItem( rtitemB )
       Call rtitemB.Remove()
       Call doc.save(False, False)
       EmbedPictureIntoRichText = True
End Function
Stan Rogers
  • 2,180
  • 11
  • 9