image url in linked resource

本小妞迷上赌 提交于 2021-01-04 04:26:32

问题


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);

回答1:


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);



回答2:


AlternateView av = AlternateView.CreateAlternateViewFromString(str,null,MediaTypeNames.Text.Html);
LinkedResource lr = new LinkedResource("E:\\Photos\\hello.jpg",MediaTypeNames.Image.Jpeg);
lr.ContentId = "image1";
av.LinkedResources.Add(lr);
message.AlternateViews.Add(av);


来源:https://stackoverflow.com/questions/19002685/image-url-in-linked-resource

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!