使用lotus.domino在Notes文档中插入图像/文件

时间:2015-06-17 04:04:10

标签: java lotus-notes lotus-domino lotusscript lotus

我正在尝试在Notes文档中插入一些内联图像和内联附件,使用lotus.domino包Java API的Rich Text格式,然后发送它。

插入代码如下。

// 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();

现在我有: enter image description here

我想要的是: enter image description here

提前致谢。

1 个答案:

答案 0 :(得分:0)

这是我在网上找到的LotusScript函数。 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