I have a service that runs on SQL Integration Services, this service reads a mailbox, and forward readed emails to other recipients, all work's fine with inline images when these are added manually using outlook editor (drag and drop, or insert image). But when email is created using VBA and inserting images as attachments and naming their 'cid' when message is readed from EWS it do not recognize images as inline images.
This is how my app reads email (NormalizedBody) from EWS when email was sent using Outlook editor and images are inserted using insert image button: (I skiped other html tags and is showing only 'img' tags):
<img src=\"cid:[email protected]\" width=\"135\" height=\"166\" id=\"Imagem_x0020_1\">
<img src=\"cid:[email protected]\" width=\"135\" height=\"166\" id=\"Imagem_x0020_2\">
<img src=\"cid:[email protected]\" width=\"135\" height=\"166\" id=\"Imagem_x0020_3\">
And the attachments properties from 'image001' as example:
ContentId: "[email protected]"
IsInline: true
Now If I create the email using outlook VBA with this code:
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = "[email protected]"
olMail.Subject = "VBA MAIL TEST"
olMail.Attachments.Add "C:\Users\Public\_testeMailing\Image001.png", olByValue, 1, "Image001"
olMail.Attachments.Add "C:\Users\Public\_testeMailing\Image002.png", olByValue, 2, "Image002"
olMail.Attachments.Add "C:\Users\Public\_testeMailing\Image003.png", olByValue, 3, "Image003"
olMail.BodyFormat = olFormatHTML
Dim strHTML As String
strHTML = "<table><tr>" & _
"<td><img src='cid:Image001.png' /></td>" & _
"<td><img src='cid:Image002.png' /></td>" & _
"<td><img src='cid:Image003.png' /></td>" & _
"</tr></table>"
olMail.HTMLBody = strHTML
olMail.Send
When read NormalizedBody from EWS, the HTML img tags are shown like this:
<img src=\"cid:342EA5ED2B36174FA24B4FFE34AD84FA@1\">
<img src=\"cid:37448D8F2D450541A18641D2EE5BB152@1\">
<img src=\"cid:3E2CFE241DBFF943B815142BC3631890@1\">
And the properties of image001 are:
ContentId: null
IsInline: false
Perhaps, if I open this email using outlook client, the mail body is showing images correctly.
But if I try to create a message forward (CreateForward()) the images turn into attachaments (not inline) and cid positioning of images are shown broken.
I think that the problem is in the way that images are inserted into message when using VBA code and not with the reading from EWS is this correct? Is there better ways to create an email using 'cid' and inline images?
Thanks, and sorry about english errors.