0

在我的程序中,用户将选择模板消息,它将显示在正文文本框中。模板为 HTML 格式。

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

我想将下面的 html 存储到字符串中。

<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;


            }

告诉我在 c# 或变量中插入此 html 代码的任何方法,或如何通过电子邮件发送此模板。(替代)我还需要在模板中放置一些参数。例如 OrderNo.xxxxxx 替换为 pid(静态包含一些值)。提前致谢

4

2 回答 2

2

将其保存到文件并将该文件加载到字符串或应用程序设置(项目->属性->设置)

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

应用程序设置:

string htmlCode = properties.Default.HtmlCode;

之后你可以做任何你想做的事。

于 2013-08-14T14:16:54.460 回答
0

你可以使用模板解析器

Codeplex 库文档

于 2013-08-14T19:41:10.577 回答