title: vba email embed image not showing
body: <p>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.</p>
  
  <p>I have an Access application to send from, but have broken it down to the code below using Excel.</p>
  
  <p>BUT</p>
  
  <p>It now works fine, if I display the email and then send it. Not doing anything else at all. Just display then send.</p>
  
  <p>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.</p>
  
  <p>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!</p>
  
  <p>Hope someone can help or has an idea! I'm not the strongest in HTLM, so it's probably something simple...</p>
  
  <p>Thanks</p>
  
  <p>John</p>
  
  <pre><code>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 = "&lt;BODY&gt;&lt;IMG src=""cid:logo.jpg"" width=200&gt; &lt;/BODY&gt;"
      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
  </code></pre>