Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image url in linked resource

Tags:

c#

uri

image

I want to embed a image from an url in c# mail, I tried using this code but it is not working

 LinkedResource logoHeader = null;
AlternateView av1 = AlternateView.CreateAlternateViewFromString(strBody, null,   MediaTypeNames.Text.Html);
logoHeader= new LinkedResource("some xyz.com");  
logoHeader.ContentId = "logoimage";
av1.LinkedResources.Add(logo);
like image 835
Mazher Ul Haq Avatar asked Jan 12 '23 07:01

Mazher Ul Haq


1 Answers

string image = "example.com/image.jpg";
var webClient = new WebClient();
byte[] imageBytes = webClient.DownloadData(image);
MemoryStream ms = new MemoryStream(imageBytes);
LinkedResource resource = new LinkedResource(ms, MediaTypeNames.Image.Jpeg);
like image 148
Suchy Avatar answered Jan 21 '23 22:01

Suchy