Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用c在运行时传递值时html标记不显示图像#_C#_Html - Fatal编程技术网

C# 使用c在运行时传递值时html标记不显示图像#

C# 使用c在运行时传递值时html标记不显示图像#,c#,html,C#,Html,我正在使用html页面发送一封邮件,在邮件中,我正在解析标记以在运行时给出它们的值。。但我的问题是我有两个img src标签。我在运行时赋予它们价值,但当收到邮件时,它只显示一个图像,而不是两个图像。。 我不知道可能是什么问题。我正在使用以下代码: XmlDocument xmlDoc = new XmlDocument(); XmlNode node = null; xmlDoc.Load(theme);

我正在使用html页面发送一封邮件,在邮件中,我正在解析标记以在运行时给出它们的值。。但我的问题是我有两个img src标签。我在运行时赋予它们价值,但当收到邮件时,它只显示一个图像,而不是两个图像。。 我不知道可能是什么问题。我正在使用以下代码:

  XmlDocument xmlDoc = new XmlDocument();
                 XmlNode node = null;
                 xmlDoc.Load(theme);
                 XmlNodeList list = xmlDoc.SelectNodes("html/body/form/div/img");
                MailMessage mail = new MailMessage();
                string from = ConfigurationManager.AppSettings["from"];
                string password = ConfigurationManager.AppSettings["password"];
                string smtp_port = ConfigurationManager.AppSettings["smtp_port"];

                if(foot_image!= "")
                {
                    Attachment imgAtt = new Attachment(foot_image);
                    imgAtt.ContentId = footimage;
                    imgAtt.ContentDisposition.Inline = true;
                    list.Item(1).Attributes[0].Value = "cid:" + imgAtt.ContentId + "";
                    mail.Attachments.Add(imgAtt);
                }

                if(file != "")
                {
                    Attachment ingatt1 = new Attachment(file);
                    ingatt1.ContentId = headimage;
                    ingatt1.ContentDisposition.Inline = true;
                    list.Item(0).Attributes[0].Value = "cid:" + ingatt1.ContentId + "";
                  //  node = xmlDoc.SelectSingleNode("html/body/form/div/img");
                  //  node.Attributes[0].Value = "cid:" + ingatt1.ContentId + "";
                    mail.Attachments.Add(ingatt1);
                }

                xmlDoc.Save(theme);

                StreamReader sr = new StreamReader(theme);
                string theme_text = sr.ReadToEnd();

                mail.To.Add(to);
                mail.From = new MailAddress(from);
                mail.Subject = "In line image test";
                mail.Body = theme_text;
                mail.IsBodyHtml = true;
请解决我的问题

我的html页面是:

<html>
  <head>
    <title>Untitled Page</title>
  </head>
  <body>
    <form>
      <div style="margin-left:50px; padding-top:10px">
        <img src="" style="width:480px; height:150px;" />
      </div>
      <div style="margin-left:50px; padding-top:20px;">
        <h1>
        </h1>
      </div>
      <div style="margin-left:50px; margin-top:200px;">
        <img src='' style="width:480px; height:150px;" />
      </div>
    </form>
  </body>
</html>

无标题页

根据我从我们的评论线程中获得的信息,第二张图片正确附加到电子邮件中存在问题。尝试发送到其他电子邮件地址以查看问题是否仍然存在。可能有一些垃圾邮件过滤正在进行,它阻止了特定的图像。

在第二个img标记中,您使用了src=''而不是src'',因此问题存在。

您应该正确标记它。这看起来像是C#,不仅仅是HTML。我想我应该转移到任何其他网站解决我的问题。这取决于你,但要想把它做好并没有那么难。@jayp:这就是我没有弄清楚的问题。请给我一个解决方案。请任何人给我一个可能的答案好吗???应该没有区别-这里允许单引号和双引号:而且,这个问题在2011年就结束了,所以这个问题可能已经解决了。