Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 14th, 2010, 07:35 AM
Authorized User
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default Sending xml format through email, format issue!!!

HI All

I am trying to send XML structure in the body of mail. I am building the structure using a stringbuilder like this:

  private XmlDocument GenerateXMLForMail(ref DataTable dtMail)
        xml = new XmlDocument();
        StringBuilder sb = new StringBuilder();
        sb.Append("<ReferenceNumber>" + string.Empty + "</ReferenceNumber>");
        sb.Append("<AssociateId>" + Session["UserID"].ToString() + "</AssociateId>");
        sb.Append("<EmployeeName>" + Session["UserName"].ToString().ToUpperInvariant() + "</EmployeeName>");
        sb.Append("<OrderTotalValue>" + lblTotal.Text.Trim() + "</OrderTotalValue>");
        sb.Append("<PointsRedeemed>" + txtAvlPoints.Text.Trim() + "</PointsRedeemed>");
        sb.Append("<Address>" + txtStreetAddress.Text.Trim() + "</Address>");
        sb.Append("<City>" + txtCity.Text.Trim() + "</City>");
        sb.Append("<State>" + txtState.Text.Trim() + "</State>");
        sb.Append("<Country>" + txtCountry.Text.Trim() + "</Country>");
        sb.Append("<PinCode>" + txtPINCode.Text.Trim() + "</PinCode>");
        sb.Append("<ContactNumber>" + txtContactNo.Text.Trim() + "</ContactNumber>");
        sb.Append("<Email>" + txtEmail.Text.Trim() + "</Email>");
        sb.Append("<Remarks>" + txtEmail.Text.Trim() + "</Remarks>");
        for (int i = 0; i < dtMail.Rows.Count; i++)
            sb.Append("<Code>" + dtMail.Rows[i]["PRODUCT_CODE"].ToString() + "</Code>");
            sb.Append("<Description>" + string.Empty + "</Description>");
            sb.Append("<Size>" + string.Empty + "</Size>");
            sb.Append("<Quantity>" + "1" + "</Quantity>");
            sb.Append("<Price>" + dtMail.Rows[i]["RATE"].ToString() + "</Price>");

        return xml;
It is successfully converting into XML and then i am assigning xml value to a string variable like this ---

strBodyText = xml.InnerXml;
After that mail is being sent. I had made the property IsBodyHtml = false. The mail is going in text format. Now the thing is the xml should go in a proper format with its nodes clearly visible, like well formed xml.

What changes i need to do in my code to achieve this feature. What else i need to do to improve the code?

-- Abhishek

Similar Threads
Thread Thread Starter Forum Replies Last Post
issue with format anarleti XSLT 6 April 23rd, 2010 09:57 AM
XML request format issue dishant XML 5 September 7th, 2009 03:10 AM
Data Format Issue---need help please zone Excel VBA 0 August 13th, 2007 04:21 PM
email in html format alitoday HTML Code Clinic 3 June 19th, 2004 08:31 AM
Sending Access Reports to PDF Format jhartwick Access VBA 1 May 2nd, 2004 08:00 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.