Html – Sending formatted Lotus Notes rich text email from Excel VBA

htmllotus-notesvba

While trying to use the hints in your answer at

Sending formatted Lotus Notes rich text email from Excel VBA

I could do almost everything I needed: write multiple lines with data from a database of mine, formatting the body by mean of html code, with links and formatted text.

I also need to put an image in the mail body, but the html code "img src="etc. does not work, maybe because the image is located on my pc and is not reached by the recipients.
I need to find a way to embed the image just like I would do by mean of the Lotus menus.
In my Italian Lotus Notes 7, there is a Create menu with an Image option, I find the image, click OK and it is done.

That's what I wish to do with my code, please tell me it's possible! 🙂

Thanks in advance.

Riccardo Baldinotti, Italy

Best Answer

Here you can find the complete code. It's too large to paste here, so I'm copying just a few lines to show the idea:

  If (bSetImages) Then
        For iImageIndex = 0 To Ubound(imageFilePaths)

              ' Get the image file path and content id (cid).
              strImagePath = Trim(imageFilePaths(iImageIndex))
              If (strImagePath = "") Then Exit Sub
              strImageCid = Trim(imageContentIds(iImageIndex))
              If (strImageCid = "") Then Exit Sub

              ' Get the image context type.
              If (StrContains(strImagePath, ".", True)) Then strImageExt = Strrightback(strImagePath, ".") Else strImageExt = ""
              Select Case Lcase(strImageExt)
              Case "gif":      strImageType = "image/gif"
              Case "jpg":      strImageType = "image/jpg"
              Case Else:      strImageType = "image/gif"
              End Select

              ' Add the image part.
              Set mimeImage = mimeBody.CreateChildEntity()
              Set mimeImageHeader = mimeImage.CreateHeader({Content-ID})
              Call mimeImageHeader.SetHeaderVal("<" & strImageCid & ">")
              Call stream.Open(strImagePath)
              Call mimeImage.SetContentFromBytes(stream, strImageType & {;name="} + strImageCid + {"}, ENC_IDENTITY_BINARY)
              Call stream.Close()

        Next
  End If
Related Topic