由C#在EmailTemplate.html中打印阵列
问题描述:
我使用WCF发送电子邮件,并且我有EmailTemplate.html页面来创建电子邮件正文。我访问,与下面的函数由C#在EmailTemplate.html中打印阵列
private string CreateBody(int formNum, string[] names)
{
string body= string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplate.html")))
{
body = reader.ReadToEnd();
}
body = body.Replace("{formNumber}", ""+formNum);
// Here I need to add code for array
return body;
}
用于访问{} formNumber现场我有传统的编码在我EmmailTemplate.HTML页面如下:
<tr>
<td width="30%">Form Number:</td>
<td width="70%"><b>{formNumber} </b></td>
</tr>
同样喜欢这一点,我有HTML代码,为其他字段..
现在我的问题是我有一个数组,需要在EmailTemplate.html中的HTML页面上打印。任何人都可以告诉我,我需要在CreateBody()方法中添加什么,以便我的数组将显示在EmailTemplate.HTML 此外,如果我需要对HTML页面进行更改,请让我知道..(Array is not的固定尺寸。) 谢谢
答
for (int i = 0; i < eng.Length; i++)
{
body += "<tr>";
body += "<td>" + acsfbv[i] + "</td>";
body += "<td>" + ZSFbz[i] + "</td>";
body += "<td>" + enginzbzxvb[i] + "</td>";
body += "</tr>";
}
数组是什么?你希望它如何显示在电子邮件中?你能分享有多个这样的项目的示例html吗? –