Search code examples
excelvbaimageemailoutlook

Receiver can't see images in Outlook Email


I am having trouble getting my images to display when I send emails in Outlook. In my email sending function, I add an inlineshape picture to the beginning of the word document and everything displays fine, but when I send the email, both the inline picture and the picture in my signature disappear. Please see the screenshots and code below. I have tried searching for answers with no success.

Sub Send_Email( _
            strTo As String, _
            Optional strFromEmail As String, _
            Optional strSubject As String, _
            Optional strCC As String, _
            Optional strBCC As String, _
            Optional BodyFormat As olBodyFormat = olFormatPlain, _
            Optional varBody1 As Variant, _
            Optional strPicturePath As String, _
            Optional lngPicutreSize As Long = 100, _
            Optional varBody2 As Variant, _
            Optional strAttachmentPath As String, _
            Optional blnSendEmail As Boolean = False)

Dim olApp As Outlook.Application
Set olApp = New Outlook.Application

Dim olEmail As Outlook.MailItem
Set olEmail = olApp.CreateItem(olMailItem)

Dim olInsp As Outlook.Inspector
Dim wdDoc As Word.document
Dim shpEmailShape As Word.InlineShape

With olEmail
    .BodyFormat = BodyFormat
    .display
    If strFromEmail <> "" Then
        .SentOnBehalfOfName = strFromEmail
    End If
    .To = strTo
    .Subject = strSubject
    .CC = strCC
    .BCC = strBCC
    If BodyFormat = olFormatHTML Then
        If varBody2 <> "" Then
            .HTMLBody = varBody2 & "<br>" & .HTMLBody
        End If
        If varBody1 <> "" Then
            .HTMLBody = varBody1 & "<br>" & .HTMLBody
        End If
    ElseIf BodyFormat = olFormatRichText Then
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        If IsMissing(varBody2) = False Then
            varBody2.Copy
            wdDoc.Range(0, 0).Paste
        End If
        If strPicturePath <> "" Then
            Set shpEmailShape = wdDoc.Range(0, 0).InlineShapes.AddPicture(strPicturePath)
            shpEmailShape.LockAspectRatio = msoCTrue
            shpEmailShape.Height = lngPicutreSize
        End If
        If IsMissing(varBody1) = False Then
            varBody1.Copy
            wdDoc.Range(0, 0).Paste
        End If
    Else
        On Error Resume Next
        If varBody2 <> "" Then
            .body = varBody2 & vbCrLf & .body
        End If
        On Error GoTo 0
        On Error Resume Next
        If varBody1 <> "" Then
            .body = varBody1 & vbCrLf & .body
        End If
        On Error GoTo 0
    End If
    If strAttachmentPath <> "" Then
        .Attachments.Add strAttachmentPath
    End If
End With

If blnSendEmail = True Then
    olEmail.send
End If

Email before sending with pictures displayed

Email after sending with pictures gone


Solution

  • It sure sounds like you are sending in the RTF format. You need to send an HTML formatted message with with an image added as an attachment and referenced by the HTML body.