【问题标题】:How to resize embedded images in email如何调整电子邮件中嵌入图像的大小
【发布时间】:2014-08-09 21:23:38
【问题描述】:

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

我正在尝试将图像的宽度调整为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>";

编辑: 我试过&lt;img width="100" src=\"cid:" + contentID + "\"&gt; 但它不起作用,

【问题讨论】:

    标签: c# html css email


    【解决方案1】:

    怎么样:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-01
      • 2023-03-27
      • 2015-11-01
      • 2018-12-24
      • 1970-01-01
      • 2010-12-23
      • 2011-10-30
      相关资源
      最近更新 更多