我正在设法用发送网格发送邮件,附件也没问题。但我在将图像嵌入HTML邮件正文时遇到问题
以下是我正在使用的代码,在阅读了有关此问题的各种示例后将它们放在一起。任何人都知道我哪里出错了,问候......
MemoryStream msLogo = new MemoryStream(obj.logo);
Bitmap b = new Bitmap(msLogo);
ImageConverter ic = new ImageConverter();
Byte[] ba = (Byte[])ic.ConvertTo(b, typeof(Byte[]));
MemoryStream logo = new MemoryStream(ba);
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(sBody, null, "text/html");
LinkedResource imageResource = new LinkedResource(logo);
var imagelink = new LinkedResource(logo, "image/png");
imagelink.ContentId = string.Format("logo", myMessage);
imagelink.TransferEncoding = TransferEncoding.Base64;
b.Save(logo, ImageFormat.Jpeg);
logo.Position = 0;