'Send by mail Excel sheet image

I have an Excel with an embedded image.

How can I send it by mail using the name of the image? I do not want to send it attached, I want to embed it in the html of the mail. It's possible?

Thank you very much in advance

An example code:

With objMail
       'Set body format to HTML
       .BodyFormat = olFormatHTML

       .To = Sheet3.Range(inTo)
       If (inAttach1 <> "") Then .Attachments.Add inAttach1
       If (inAttach2 <> "") Then .Attachments.Add inAttach2
       If (Sheet3.Range(inCC) <> "") Then .CC = Sheet3.Range(inCC)

       sBody = Sheet1.Range("B2").Value
       '----insert Name
       iPos = InStr(1, sBody, "[FirstName]", vbTextCompare)
       iPos2 = iPos + Len("[FirstName]")
       sText1 = Mid(sBody, 1, iPos - 1)
       sText2 = Mid(sBody, iPos2, Len(sBody) - iPos2 + 1)
       sBody = sText1 & Sheet3.Range(inName) & sText2


       .Subject = inSubj
       .SentOnBehalfOfName = inFrom
       .HTMLBody = sBody
       'Importancia mail
       '.Importance = olImportanceHigh
       .sEnd
    End With


Solution 1:[1]

This might work for you: http://www.rondebruin.nl/win/s1/outlook/bmail3.htm

You can send a worksheet or a selection as the body of an email, and it will include any applicable images(on the worksheet or in the selected area).

Sub Send_Selection_Or_ActiveSheet_with_MailEnvelope()
'Working in Excel 2002-2016
    Dim Sendrng As Range

    On Error GoTo StopMacro

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    'Note: if the selection is one cell it will send the whole worksheet
    Set Sendrng = Selection

    'Create the mail and send it
    With Sendrng

        ActiveWorkbook.EnvelopeVisible = True
        With .Parent.MailEnvelope

            ' Set the optional introduction field thats adds
            ' some header text to the email body.
            .Introduction = "This is a test mail."

            With .Item
                .To = "[email protected]"
                .CC = ""
                .BCC = ""
                .Subject = "My subject"
                .Send
            End With

        End With
    End With

StopMacro:
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    ActiveWorkbook.EnvelopeVisible = False

End Sub

Solution 2:[2]

Create an attachment and set the PR_ATTACH_CONTENT_ID property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x3712001F") using Attachment.PropertyAccessor.

Your HTML body (MailItem.HTMLBody property) would then need to reference that image attachment through the cid:

img src="cid:xyz"

where xyz is the value of the PR_ATTACH_CONTENT_ID property.

Look at an existing message with OutlookSpy (I am its author) - click IMessage button.

attachment = mailitem.Attachments.Add("c:\temp\MyPicture.jpg")
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "MyId1")
mailitem.HTMLBody = "<html><body>Test image <img src=""cid:MyId1""></body></html>"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AirWreck
Solution 2