【发布时间】:2021-06-10 11:41:40
【问题描述】:
我正在尝试发送带有超链接到 html 电子邮件模板的列表,该列表包含多个项目(文档路径),但我只能在电子邮件中获取一个项目(列表中的第一项)。
asp.net 代码:
private string GetEmailBody(List<string> blob)
{
string strContent = string.Empty;
StringBuilder body = new StringBuilder();
var webRequest = WebRequest.Create(@"https://email template path");
using (var response = webRequest.GetResponse())
using (var content = response.GetResponseStream())
using (var reader = new StreamReader(content))
{
strContent = reader.ReadToEnd();
}
var emailBody = strContent;
body.Append(emailBody);
foreach (var path in blob.ToList())
{
body.Replace("{{Report.Path}}", path.ToString());
}
foreach (var name in fileName.ToList())
{
body.Replace("{{Report.Name}}", name.ToString());
}
return body.ToString();
}
}
blob.ToList 包含路径列表。
fileName.ToList 包含文件名列表。
电子邮件 HTML 模板:
<div align="center">
<p>
<ul>
<li>
<a href="{{Report.Path}}" class="button">{{Report.Name}}</a>
</li>
</ul>
</p>
</div>
我也尝试过使用 *ngFor 但没有成功。
我想展示这样的东西。目前它只显示 1 份报告,我需要列表中的所有报告 [
感谢任何建议/建议和帮助。谢谢
【问题讨论】:
标签: c# html list asp.net-core