简体   繁体   English

通过C#在EmailTemplate.html中打印数组

[英]Printing an Array in EmailTemplate.html by C#

I am using WCF for sending the Email and I have EmailTemplate.html page to create Email Body. 我正在使用WCF发送电子邮件,并且我具有EmailTemplate.html页面来创建电子邮件正文。 I am accessing that with following function 我正在通过以下功能访问它

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

For Accessing the {formNumber} Field I have traditional coding in my EmmailTemplate.HTML page as follows: 为了访问{formNumber}字段,我在EmmailTemplate.HTML页面中使用了传统的编码,如下所示:

                  <tr>
                   <td width="30%">Form Number:</td>
                   <td width="70%"><b>{formNumber} </b></td>
               </tr>

Same like this I have HTML code for other fields.. 像这样我有其他领域的HTML代码。

Now my problem is I got an Array that needs to print on HTML page in EmailTemplate.html. 现在我的问题是我得到一个需要在EmailTemplate.html的HTML页面上打印的数组。 Can anyone please tell me that what I need to add in CreateBody() method so that my array will get shown in EmailTemplate.HTML Also, If I need to make changes on my HTML page please let me know.. (Array is not of Fix size.) Thank You 谁能告诉我我需要在CreateBody()方法中添加的内容,以便使我的数组显示在EmailTemplate.HTML中。此外,如果需要在HTML页面上进行更改,请告诉我。。(数组不属于固定尺寸。)谢谢

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM