I'm trying to run code in VBA that will send out HTML emails and am trying to embed an image within the email. I have the following code to do so:

```
Sub EmailImage()

Dim oApp As Outlook.Application
Dim oEmail As MailItem
Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment

Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(olMailItem)
Set colAttach = oEmail.Attachments
Set oAttach = colAttach.Add("C:\Users\User1\Documents\thumbs-up.jpg")
oEmail.Close olSave
oEmail.To = "abc@abc123.com"
oEmail.HTMLBody = "<IMG alt='' hspace=0 src='cid:thumbs-up.jpg' align=baseline border=0>&nbsp;</BODY>"
oEmail.Send
Set oEmail = Nothing
Set colAttach = Nothing
Set oAttach = Nothing
Set oApp = Nothing

End Sub

```

But what happens is that the image gets attached but there's a box with a red cross in it where the image should be, as is shown in the below image:

[![enter image description here](https://i.stack.imgur.com/nlXa2.png)](https://i.stack.imgur.com/nlXa2.png)

I have tried the following adapton to the code:

```
Sub EmailImage()
Dim oApp As Outlook.Application
Dim oEmail As MailItem
Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment

Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(olMailItem)
Set colAttach = oEmail.Attachments
Set oAttach = colAttach.Add("C:\Users\User1\Documents\thumbs-up.jpg")

oAttach.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "MyCid")

oEmail.Close olSave
oEmail.To = "abc@abc123.com"
oEmail.HTMLBody = "<IMG alt='' hspace=0 src='cid:MyCid' align=baseline border=0>&nbsp;</BODY>"
oEmail.Send
Set oEmail = Nothing
Set colAttach = Nothing
Set oAttach = Nothing
Set oApp = Nothing
End Sub

```

But this gives me the error "Compile error: expected =" on the line `oAttach.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "MyCid")` so I tried to take out the `, "MyCid")` and changed the code in the email to just `oEmail.HTMLBody = "<IMG alt='' hspace=0 src='cid:thumbs-up.jpg' align=baseline border=0>&nbsp;</BODY>"` again, so that it looks like this:

```
Sub EmailImage()

Dim oApp As Outlook.Application
Dim oEmail As MailItem
Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment

Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(olMailItem)
Set colAttach = oEmail.Attachments
Set oAttach = colAttach.Add("C:\Users\User1\Documents\thumbs-up.jpg")
oAttach.PropertyAccessor.SetProperty ("http://schemas.microsoft.com/mapi/proptag/0x3712001F")

oEmail.Close olSave
oEmail.To = "abc@abc123.com"
oEmail.HTMLBody = "<IMG alt='' hspace=0 src='cid:thumbs-up.jpg' align=baseline border=0>&nbsp;</BODY>"
oEmail.Send
Set oEmail = Nothing
Set colAttach = Nothing
Set oAttach = Nothing
Set oApp = Nothing

End Sub

```

But I now get the error `Compile error: argument not optional` with it pointing at the `.SetProperty` part of the line `oAttach.PropertyAccessor.SetProperty ("http://schemas.microsoft.com/mapi/proptag/0x3712001F")`.

Please note that I am using Windows 7, Microsoft Excel 2010 and Microsoft Outlook 2010.