Search code examples
c#emailimageurleml

Retrieve and display inline images from email when encoded as a CID with c#


I need the image URL from the following cid code in the physical path

<img id="Picture_x0020_6" src="cid:[email protected]" alt="cid:[email protected]" />

as

<img id="Picture_x0020_6" src="~/images/image009.png" alt="image009.png" />

Solution

  • You need to find the corresponding hidden attachment and then save it on the disk. The SaveAsFile method of the Attachment class saves the attachment to the specified path. Then you can upload it to any web server or just make it available globally and change the src attribute in the message body.