【问题标题】:Printing an Array in EmailTemplate.html by C#用 C# 在 EmailTemplate.html 中打印一个数组
【发布时间】:2018-03-03 13:57:35
【问题描述】:

我正在使用 WCF 发送电子邮件,并且我有 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 页面上进行更改,请告诉我..(数组不是固定大小的。) 谢谢你

【问题讨论】:

  • 什么数组?您希望它如何在电子邮件中显示?您可以分享包含多个此类项目的示例 html 吗?

标签: javascript c# html wcf email


【解决方案1】:
        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>";
        }

【讨论】:

    猜你喜欢
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 2011-07-07
    • 1970-01-01
    • 2011-02-09
    • 1970-01-01
    • 1970-01-01
    • 2014-02-25
    相关资源
    最近更新 更多