1

I'm using outlook 2016 and Excel 2016. I have written a code to paste a email in the outlook body. My email body contains html codes which has image included,the code works fine however I'm not able to paste the image in the email body. Please help.

Please find the vba code below.

Sub Send_Mails()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim subj As String
    Dim recp As String
    Dim bccrep As String
    Dim ccrecp As String
    Dim i As Integer


    For i = 2 To 10

        Sheets("Email Draft").Select
        strbody = Sheets("Email Draft").Range("C1")
        subj = "Welcome - " & Sheets("Macro").Range("O" & i)
        recp = Sheets("Macro").Range("I" & i)
        ccrecp = Sheets("Macro").Range("J" & i)
        bccrep = Sheets("Macro").Range("K" & i)

        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)

        With OutMail
            .To = recp
            .CC = ccrecp
            .BCC = bccrep
            .Subject = subj
            .HTMLBody = .HTMLBody & strbody
            .Display
        End With

        Set OutMail = Nothing
        Set OutApp = Nothing

    Next i

End Sub

1 Answers1

1

If you appending HTML to the existing HTML message body you are likely adding content outside of the element and it won't be visible. You have to modify what is in the element. As an alternative to manipulating the HTML string, you can use the Word Object Model to change the body content via Inspector.WordEditor.

Eric Legault
  • 5,706
  • 2
  • 22
  • 38