image url in linked resource

前端 未结 2 1190
栀梦
栀梦 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);
    

提交回复
热议问题