image url in linked resource

前端 未结 2 1156
栀梦
栀梦 2021-01-21 05:36

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 = AlternateVie         


        
相关标签:
2条回答
  • 2021-01-21 06:07
    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);
    
    0 讨论(0)
  • 2021-01-21 06:07
    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);
    
    0 讨论(0)
提交回复
热议问题