我有以下一段工作​​正常的代码,
我可以发送带有附件的电子邮件。

我正在尝试将图像调整为100px;的宽度

msg.IsBodyHtml = true;
Attachment inlineLogo = new Attachment(@"C:\Desktop\Image.jpg");
msg.Attachments.Add(inlineLogo);
string contentID = "Image";
inlineLogo.ContentId = contentID;

//To make the image display as inline and not as attachment

inlineLogo.ContentDisposition.Inline = true;
inlineLogo.ContentDisposition.DispositionType = DispositionTypeNames.Inline;

//To embed image in email

msg.Body = "<htm><body> <img src=\"cid:" + contentID + "\"> </body></html>";


编辑:
我尝试了<img width="100" src=\"cid:" + contentID + "\">,但是它不起作用,

最佳答案

怎么样:

msg.Body = "<htm><body> <img width='100px' src=\"cid:" + contentID + "\"> </body></html>";


或符合W3C:

msg.Body = "<htm><body> <img style='width: 100px' src=\"cid:" + contentID + "\"> </body></html>";

关于c# - 如何调整电子邮件中嵌入式图像的大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24304904/

10-14 09:37