Our Blog

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

Bruno Grange

A passionate by software and a business enthusiast. Check out more about me at http://www.brunogrange.com

  • Diego

    Hi Bruno, great function! I googled it and your page appeared as the first result. 😉 Keep in touch.

    Diego Liberman

  • Pingback: Lotus Notes VBA: create mail with visible image without NotesUIWorkspace()

  • Ex Han

    Hi Bruno great function . I found some good in form of your post .

    Can your plese help me more to solve this issue . I have an android Application that take the snap and sample it to 300 * 300 . following snap i required to attached in lotus notes document to display on customer document.

    Can it it possible to help me to solve this issue.