0

Using Excel VBA, I am trying to add image to the mail body rather than an attachment of the mail. I tried the below code in which shows the image as body by adding image as an attachment to the mail, also it hides the attachment from the mail but the problem is mail shows the attachment symbol in the inbox. Where as the image attachment is hidden from from the mail.

Is there any better way to add the image as an content of the body and not as an attachment.

On Error Resume Next
        With OutMail
            .To = ABC
            .CC = ""
            .BCC = ""
            .Subject = "Happy Diwali"
            .Attachments.Add "C:\Users\User~1.test\AppData\Local\Temp\NamePicture.jpg", 1, 0
            'Note: Change the width and height as needed
            .HTMLBody = "<html><body><center><p><b><font size=""6"" color=""purple"">" & "Dear," & "</p><p>" & strEmpFrstNm & " and Family" & "</font></b></p><img src=""cid:NamePicture.jpg"" width=1000 height=950> </image></center></body></html>"
            .Send
        End With
        Mail_JPG_Range_Outlook = True
    On Error GoTo 0

Image

BigBen
  • 38,994
  • 6
  • 24
  • 37
Chetna S
  • 19
  • 3
  • 1
    Possible duplicate of [How to embed an image into an Outlook email using VBA](https://stackoverflow.com/questions/58617458/how-to-embed-an-image-into-an-outlook-email-using-vba) – niton Nov 09 '20 at 16:43
  • https://stackoverflow.com/a/38906686/4539709 – 0m3r Nov 09 '20 at 22:52

0 Answers0