7

I store emails and their attachments in a database. I'm using a WPF WebBrowser and the NavigateToString method to display the html body of emails. It works but when emails use embedded images with a content id (cid), i can't display them. I saved all embedded images as attachments when i save emails in database. I could create and store images in temporary files of the current user and replace cid references with an absolute path on user's disk but i think it's not the best way...

Have you got some ideas ?

Nico
  • 575
  • 3
  • 8
  • 19

1 Answers1

18

I finally found a good way :

I replaced the cid references of all images with base64 image data (RFC 2557) like this :

<img src="data:image/png;base64,RAAAtuhhx4dbgYKAAA7...more data....." alt="test">

You can use the following code to generate the base64 string :

string base64Str = Convert.ToBase64String(File.ReadAllBytes(@"C:\Temp\test.png"));

Remarks : doesn't work with IE6

Nico
  • 575
  • 3
  • 8
  • 19