I have an odd experience here. I have had loads of problems embedding a logo or image to emails using the src=cid... found out it wont show if not setting size for example.
I have an Access application to send from, but have broken it down to the code below using Excel.
BUT
It now works fine, if I display the email and then send it. Not doing anything else at all. Just display then send.
If I send directly from vba, the image will not display properly. The attachment symbol shows and Outlook itself will put the image inline, but say, gmail, wont. It's not gmails fault, as the attachmet symbol shows in Outlook. It doesn't if I display and then send.
I suspect it's still something with sizing or placing. Without the width part, Outlook will still show the image at correct place, but still show as attachment. So when you display and press send then there must me another attribute set or something. I cannot find out what!
Hope someone can help or has an idea! I'm not the strongest in HTLM, so it's probably something simple...
Thanks
John
Sub test()
Dim oApp As Outlook.Application
Dim oEmail As MailItem
Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment
'create new Outlook MailItem
Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(olMailItem)
'add graphic as attachment to Outlook message
'change path to graphic as needed
Set colAttach = oEmail.Attachments
Set oAttach = colAttach.Add("C:\temp\logo.jpg")
oEmail.Close olSave
'change the src property to 'cid:your picture filename'
'it will be changed to the correct cid when its sent.
oEmail.HTMLBody = "<BODY><IMG src=""cid:logo.jpg"" width=200> </BODY>"
oEmail.Save
oEmail.To = "someemailtogoinhere@gmail.com"
oEmail.Subject = "test"
oEmail.Display
'oEmail.Send
Set oEmail = Nothing
Set colAttach = Nothing
Set oAttach = Nothing
Set oApp = Nothing
End Sub