Displaying inline images

Feb 19, 2009 at 8:43 PM
How can I display the inline images?  I'm using a WPF application with the embeded web browser.  I can successfully show the message by pointing the browser to the content stream, but the images don't display.

Thanks.

J
Coordinator
Feb 21, 2009 at 9:11 AM
I'm not quite sure if I see exactly what is you issue here. The inline images are stored in the alternate views as linked resources. They are accessible as binary data through the ContentStream member. For instance:

myStream = message.AlternateViews[1].LinkedResources[0].ContentStream

I guess you could use this as a source for a Bitmap in your wpf application.

Snorre

Feb 21, 2009 at 6:10 PM
Edited Feb 21, 2009 at 6:29 PM
Basically I was just trying to figure out a way to get it all displayed properly in a browser. But it seems there is no "easy" way. I had to save out the linked resources to a temp folder and then edit the html view to update the image src references. I guess my question should have been "Is there an easy way to translate the view and resources into a proper html document?"

Anyway, I've got that bit covered, really. Just had to resort to the temp files.

But there is a parsing issue:

A bit of background... In my project, all of the messages are Exchange journal messages that wrap the original message as an attachment. So for each one, I parse the journal message and look for the attachment, which will always be another message. I pull that content and pass it back to the parser:


StreamReader r = new StreamReader("C:\\journal\\worddoc.eml");
StringReader reader = new StringReader(r.ReadToEnd());
MailMessage message = MailMessageMimeParser.ParseMessage(reader);

StreamReader r2 = new StreamReader(message.Attachments[0].ContentStream);
StringReader reader2 = new StringReader(r2.ReadToEnd());
MailMessage m2 = MailMessageMimeParser.ParseMessage(reader2);


The simpler ones, such as the bcc.eml file I sent in a previous post, parse without issue. But more complex emails are not getting parsed properly. Inline attachments such as the images for the html view are getting added as normal attachments. (As if the FixStandardFileds logic needs to be applied at additional times during the parse.)

I've attached a sample message that has this issue.

I'll be looking into this to, but perhaps you'll pick it out faster, as you're somewhat more familiar with the code...

Jerry