如何将html代码电子邮件模板存储在字符串变量或文本框c#中
本文关键字:变量 字符串 文本 存储 html 代码 电子邮件 | 更新日期: 2023-09-27 18:27:35
在我的程序中,用户将选择模板消息,它将显示在正文文本框中。该模板为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> </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> </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> </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代码的任何方法,或者如何通过电子邮件发送此模板。(可选)我还需要在模板中放入一些参数。例如,将订单号xxxxxx替换为pid(静态包含一些值)。感谢提前
将其保存到文件中,并将该文件加载到字符串中,或在应用程序设置(项目->属性->设置)中
string htmlCode = System.IO.File.ReadAllText("File Path");
应用程序设置:
string htmlCode = properties.Default.HtmlCode;
在那之后,你可以做任何你想做的事。
您可以使用模板解析器
Codeplex库和文档