Follows a simple LotusScript function that will embed a file system picture (strFilePath As String) into the Body RichText field of a Notes document (doc As NotesDocument). This will not embed as an icon, but as the image itself.
Function EmbedPictureIntoRichText(doc As NotesDocument, strFilePath As String) As Boolean
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
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() 'Set childEntity = richTextItemObj.CreateChildEntity()
fileFormat = "image/jpeg" 'Other formats are "image/gif" "image/bmp"
Call child.Setcontentfrombytes(stream, fileFormat, 1730)
Call stream.Close()
Call doc.save(false, false) 'JUST TO REFRESH
Set rtitemA = doc.GetFirstItem("Body")
Set rtitemB = doc.GetFirstItem("DummyRichText")
Call rtitemA.AppendRTItem( rtitemB )
Call rtitemB.Remove()
Call doc.save(False, False)
EmbedPictureIntoRichText = True
End Function
Good day.
ResponderExcluirPerhaps you can help me?
There is a need to include images from Resources/Images
You don't know how to do it?