0

In my program user will select template message and it will show up in the body textbox. The template is in HTML Format.

if(templatelistbox.SelectedItem.ToString().Equals("Order Processing"))
            {
string m;

i want to store the below html to string.

<body>
<table width="580" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tbody>
    <tr>
      <td colspan="2" align="right" valign="middle" width="580" height="60" bgcolor="00496f"><div wotsearchtarget="flipkart.com"></div></td>
    </tr>
    <tr>
      <td colspan="2" align="left" valign="middle" width="580" bgcolor="3bb1d7"><p><strong>Order Confirmed!</strong></p></td>
    </tr>
    <tr>
      <td colspan="2" align="left" valign="top" width="580" bgcolor="ffffff"><p>&nbsp;</p>
        <p>Dear <strong>Praveen,</strong></p>
        <p>Greetings from Prostyle PC Kart</p>
        <p>We thank you for your order. This email contains your order summary. When the item(s) in your order are ready to ship, you will receive an email with the Courier Tracking ID and the link where you can track your order. You can also check the status of your order on <strong>ebay.in</strong></p>

        Please find below the summary of your order <strong> OD3</strong></a>
        at Prostyle Pc Kart Seller of eBay.in:
        </p></td>
    </tr>
    <tr>
      <td colspan="2" align="left" valign="top" width="580" bgcolor="ffffff"><table border="0" cellspacing="0" cellpadding="0" width="580">
        <tbody>
          <tr>
            <td colspan="7"><p><strong>Order ID: OD3
                |  Seller ID : eshop.prostylepc.in</strong></p>
              <p>                <strong>Item (s) Ordered:</strong></p></td>
          </tr>
          <tr>
            <td width="274" valign="top"><p><strong>Product Details</strong></p></td>

            <td width="112" valign="top"><p><strong>Shipping Date</strong></p></td>
            <td width="62" valign="top"><p><strong>Ordered Quantity</strong></p></td>
            <td width="132" valign="top"><p><center><strong>Price</strong></center></p></td>


          </tr>
          <tr>
            <td width="274" valign="top"><p>XOLO Q800</p>
              </td>
            <td width="112" valign="top"><p>&nbsp;</p></td>
            <td width="62" valign="top"><center><p>1</p></center></td>
            <td width="132" valign="top" align="center"><p>Rs. 9700</p></td>

          <tr>
            <td width="274" valign="top"><p>Samsung BHM1100NBEGINU In-the-ear Headset without Charger</p>
              </td>
            <td width="112" valign="top"><p>&nbsp;</p></td>
            <td width="62" valign="top"><center><p>1</p></center></td>
            <td width="132" valign="top" align="center"><p>Rs. 699</p></td>


          </tr>
          <tr>
            <td colspan="2"><p>Shipping Charge</p></td>
            <td width="62"><center><p>FREE</p></center></td>
          </tr>
          <tr>
            <td valign="top" colspan="3"><p><strong>Total</strong></p></td>
            <td width="132" valign="top"><p><strong>Rs. 9700</strong></p></td>
          </tr>
          <tr>
     .......................................................




bodytbox.Text = m;


            }

Tell me any way to insert this html code in c# or variable or how to send this template via a email.(Alternative) I alos need to put some parameter in the template.For Eg OrderNo.xxxxxx replaced with pid(static contain some value). Thanks In advance

1
  • 1
    Put it in a file and read the file. Commented Aug 14, 2013 at 14:06

2 Answers 2

2

save it to file and load that file to string , or in the application setting ( project -> properties -> setting )

string htmlCode = System.IO.File.ReadAllText("File Path");

with application setting :

string htmlCode = properties.Default.HtmlCode;

after that you can do what ever you want that.

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

2 Comments

It working But i need to put some parameter in the template.For Eg ORder no replaced with paisapayid(static).
Just Try this thing for example if you have this string " Welcome User " and you want to add the user name after the that all you need to do just do something like that " Welcome User {0} " notice the {0} now using string.Format(" Welcome User {0} " , "the alghbban") it will replace the {0} with the string you pass to it , if have 10 places you want to pass value to it just go with {0} , {1} , {2} ... and using the string.Format with what ever number of param you want I hop this help you
0

you can use Template parser

Codeplex library and Documentation

Comments

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.