2011-05-24 43 views
0

我使用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> 
+0

您應該對此進行正確標記。這看起來像C#,而不僅僅是HTML。 – 2011-05-24 15:59:34

+0

我想我應該搬到任何其他網站來解決我的問題.. – kawade 2011-05-24 16:17:52

+0

這取決於你,但確實沒有那麼難。 – 2011-05-24 16:18:30

回答

1

根據我從我們的評論跟帖有信息,有第二張圖片正確附加到電子郵件中時出現問題。嘗試發送到其他電子郵件地址,以查看問題是否仍然存在。可能會發生一些垃圾郵件過濾,阻止該特定圖像。

+0

偉大的buddy.perfect答案......非常感謝..... – kawade 2011-05-24 17:19:31

0

在第二個img標籤中,您使用了src =''而不是src =「」,所以存在問題。

+0

應該沒有區別 - 單引號和雙引號都允許在這裏:http://stackoverflow.com/questions/2373074/single-vs-double-quotes-vs此外,問題是關閉在2011年,所以問題是可能固定。 – Artemix 2013-07-23 12:09:27

相關問題