【问题标题】:Image does't show when i am sending email message发送电子邮件时图像不显示
【发布时间】:2012-07-24 03:22:40
【问题描述】:

我正在使用以下部分代码向我们的客户发送电子邮件消息,例如新闻信件。它发送正确,但我在发送电子邮件时遇到了一个小问题。现在我用 HTML 代码发布一些图片。图片未显示在电子邮件中。请帮我解决此问题..

这是我的部分代码:

    msg.To = wemail;
                            //msg.Bcc = "bcc email";
                            msg.BodyFormat = MailFormat.Html;
                            msg.Body = "<html xmlns='http://www.w3.org/1999/xhtml'><head><title>Untitled Document</title></head><body><table width='506' style='border-style:solid; border-radius:5px;' ><tr><td width='496'>  <img src='../images/logo1.jpg' alt='' width='508' /></td></tr><tr>  <td height='1px'><hr /></td></tr><tr style='border:0px; background:#6CF;'>  <td align='left' style='border-bottom:1px;'><p><b>Dear Team,</b></p>    <p><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  This mail is to inform you ....</b></p>    <p><u><b>Note : </b></u></p>    <p><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ....&nbsp;</i>     </p>     <form action='http://xxx.in' method='post' target='_blank'>  <!--  <form id='form1' name='form1' method='post' action=''>-->      <b>      Please Click Here : </b>        <input type='submit' name='btn_submit' id='btn_submit' onclick='window.location.href='http://xxx.in'' value='Visit our 'Portal' ' />     </form><br /><br /></td></tr><tr style='border-top:#000'>  <td> <img src='../images/Untitled-2.gif' alt='' /></td></tr></table></body></html>";

【问题讨论】:

    标签: c# asp.net c#-4.0 html-email


    【解决方案1】:

    您需要提供图片的完整网址,而不仅仅是&lt;img src='../images/logo1.jpg' alt='' width='508' /&gt;

    提供 .jpg 文件的确切路径

    如果你想嵌入你的邮件,那么你必须使用像&lt;img src="cid:whatever"&gt;这样的'cid'。电子邮件客户端需要“src=cid:”部分才能将标签识别为嵌入图像,而“不管什么”部分是 LinkedResource 图像的实际 Content-Id。

    更多信息可以看这里:http://www.systemnetmail.com/faq/4.4.aspx

    【讨论】:

    【解决方案2】:

    您需要提供图片的绝对网址。否则不会显示。

    喜欢

    <img src="http://yoursite.com/imGges/image.jpg" />
    

    【讨论】:

      【解决方案3】:

      您需要图像的绝对 URL。如果您将 "../images/logo1.jpg" 作为图像 URI,则电子邮件客户端将不知道从哪里获取它。将图像上传到 Web 服务器并使用 "http://exam.ple/images/logo1.jpg" 作为 URL。如果你这样做,大多数客户端仍然不会自动加载外部图像,因为它可以用于跟踪等。

      您可以将电子邮件编码为多部分 mime,并将图像嵌入到电子邮件中。见How to embed images in html email

      【讨论】:

      • 现在我在使用 Intranet 站点。我这样做是什么?
      • 查看我提到的链接。您需要从 ASP.net 执行等效操作。也许这有帮助:asp.net/web-forms/videos/how-do-i/…
      猜你喜欢
      • 2020-12-07
      • 1970-01-01
      • 2018-09-01
      • 1970-01-01
      • 2020-05-03
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      • 2011-10-17
      相关资源
      最近更新 更多