【发布时间】:2020-04-23 07:47:13
【问题描述】:
我创建了一个带有 React 模板的 .Net Core WebAPI 项目。现在我想从 API 发送一封带有电子邮件模板的电子邮件。模板为 Html 格式,因此我们需要从根路径读取 Html 文件作为模板,但默认情况下,此项目中不提供“wwwroot”路径。
我在之前的 .Net Core MVC 项目中已完成此操作,如下所示,但由于没有“WWWRoot”文件夹,我不知道如何在当前项目中执行此操作。谁能帮我知道这个模板文件的存储位置以及如何在 c# 中将其作为字符串检索?
//Get the email template path
string templatePath = RuntimeConfig.SiteUrl + "/Template/EmailTemplate.html";
//Adding the template to the email body
using (var client = new WebClient())
{
string reader = client.DownloadString(templatePath);
StringBuilder sb = new StringBuilder();
sb.Append(reader);
....
.... --logics---
}
【问题讨论】:
标签: c# api email asp.net-core .net-core