0

i am using html page to send a mail, in which i am parsing the tags to give their value at run time.. but my problem is i have two img src tags. i am giving them value at run time, but as the mail is recieved it is showing only one image not both.. i don't know what might be the problem is. i am using the below code:

  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;

please sort out my problem..

my html page is:

<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>
12
  • You should tag this properly. That looks like C#, not just HTML. Commented May 24, 2011 at 15:59
  • i think i should move to any other site for my problems.. Commented May 24, 2011 at 16:17
  • That's up to you, but it's really not that difficult to get it right. Commented May 24, 2011 at 16:18
  • @jayp: that's what i am not getting to how to get right..please provide me the solution.. Commented May 24, 2011 at 16:19
  • can please anyone provide me the possible answer???? Commented May 24, 2011 at 16:25

2 Answers 2

1

Based on the information I have from our comment thread, there is a problem with the second image being attached to the email correctly. Try sending to a different email address to see if the problem still exists. There could be some spam filtering going on thats blocking that specific image.

Sign up to request clarification or add additional context in comments.

Comments

0

In 2nd img tag you have used src='' instead of src="", so problem exists.

1 Comment

There should be no difference - both single and double quotes are allowed here: stackoverflow.com/questions/2373074/single-vs-double-quotes-vs Also, the question is closed back in 2011, so the problem is likely fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.