rdk1992
rdk1992

Reputation: 406

getting external images from email c#

am using htmlagilitypack to parse the html and get the src value of the images. I made my workaround for attachments and works fine. Fileattachment.content made the job. But i dont know how to work with an image in the html that makes reference to another site, i mean its not an attachment of the email. I get the src value of the images in the html have no problem with that, htmlagilitypack is a great api. But how do i after getting the src value of the external image, get that image and store it in a byte of arrays for saying an example. I have no intentions of storing this images in disk.

Upvotes: 0

Views: 263

Answers (1)

Dmitriy Khaykin
Dmitriy Khaykin

Reputation: 5258

Since you have the image URL, you can make a WebRequest to that URL, and you will receive back the image in the form of a response stream;

You can store the content of the response stream in a byte[] array and save that to your database. You may want to store some additional data such as the type of the image in another column, particularly if you will be displaying the images later from your database.

Does this help?

Upvotes: 1

Related Questions