Exchange Server TechCenter >
Exchange Server Forums
>
Development
>
EWS Managed API and inline images
EWS Managed API and inline images
- Is it possible for us to retrieve inline images via the EWS Managed API? If not what is the best to handle this the emails with inline all look like they have broken link images when they are rendered in our client.
I would even be open to attaching them to the email message as an actual attachment just so the user would be able to them. If it is not possible retrieve these images is there a plan to add this feature to the EWS Managed API?
All Replies
Is it possible for us to retrieve inline images via the EWS Managed API? If not what is the best to handle this the emails with inline all look like they have broken link images when they are rendered in our client.
Hi RPDev,
I would even be open to attaching them to the email message as an actual attachment just so the user would be able to them. If it is not possible retrieve these images is there a plan to add this feature to the EWS Managed API ?
yes you can use inline images with EWS Managed API. To insert an inline image, use:
FileAttachment attachment =msg.Attachments.AddFileAttachment(a.Filename, a.Data); attachment.IsInline = true; attachment.ContentType = "GIF/Image";
if you retrieve a mail with inline images, just check for the "IsInline" property in the attachments.
Was this what you're looking for?- Thanks for your reply,
I need to know how to retrieve an inline that is already in a message? To me it looks as if EWS is not exposing inline images. In the body I get something like <img src="cid:76351935-49c3-4018-9a6e-a178fe0e1f8c">. If I am correct in saying EWS is not exposing them right now are there plans to add this feature in the future.
Any advice on this would be helpful.
Btw we are on Exchange 2007 sp1, - Well for me it (kinda) works.
If I open a mail with inline attachments they show up in the attachment list, so in your case:
should give you the image file.foreach (Attachment a in msg.Attachments) { if(a.Name.Equals("76351935-49c3-4018-9a6e-a178fe0e1f8c")) { a.Load(); MemoryStream ms = <span class=code-keyword>new</span>MemoryStream(((FileAttachment)a).Content); Image returnImage = Image.FromStream(ms); } }
The only problem for me is that not all image attachments have the "IsInline" property set correctly... - Thaks for your response,
I never get the CID as for the name, I get a name of "Picture (Device Independent Bitmap)".
The inline image is really an ItemAttachment when I look into the object most attributes are null such as content type and such Although I can see an Exchange ID for that item. - I did some further testing with this and it seems I was a bit wrong, here is where I currently stand:
- the Attachment.ContentId property is the property that matches with the id given in the body (<img src="cid:bla">)
- the Attachment.ContentId property is always null if the image isn't inline
- the Attachment.IsInline is set correctly when the mail was sent from another exchange account (it was not correctly set with mails I copied from an imap account)


