我使用html页面发送邮件,其中我解析标签以在运行时给出它们的值..但我的问题是我有两个img src标签。我给他们在运行时的价值,但作为邮件收到它只显示一个图像不是两个.. 我不知道可能是什么问题是。我使用下面的代码:在运行时使用c传递值时html标记不显示图像#
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>
您应该对此进行正确标记。这看起来像C#,而不仅仅是HTML。 – 2011-05-24 15:59:34
我想我应该搬到任何其他网站来解决我的问题.. – kawade 2011-05-24 16:17:52
这取决于你,但确实没有那么难。 – 2011-05-24 16:18:30