提问人:Carlos Rozo 提问时间:9/6/2023 更新时间:9/6/2023 访问量:44
我尝试使用HTML文件发送电子邮件进行结构。但它返回了纯文本
im trying to send an email using an html file for structure. but its returning me the plain text
问:
所以我对编程很陌生,负责发送电子邮件。电子邮件被发送。 但似乎我要么不使用 HTML。或者我以某种方式重写或删除它。有人可以帮我了解我做错了什么吗?我附上了发送电子邮件的一段代码。如果您需要更多,请告诉我
if (oInf.Error == 0)
{
string templateFilePath = AppDomain.CurrentDomain.BaseDirectory + "spwebfiles\\template.html";
string template = "";
using (StreamReader rd = new StreamReader(templateFilePath))
{
template = rd.ReadToEnd();
}
//all these values comes from an an LIstobj, asume they are already filled.
StringBuilder emailBody = new StringBuilder();
emailBody.AppendLine($"Cliente: {companyName}<br>");
emailBody.AppendLine("Módulo: Inventario<br>");
emailBody.AppendLine($"Estación: {stationId}<br>");
emailBody.AppendLine("<br>");
foreach (var InventoryOffline_Model in oInf.ListObj)
{
///sending a block of code, this will happen n# times as i might send several items or just 1
string docName = THelperApp.GetDocName(InventoryOffline_Model.TranType);
string block = string.Format(
"<br>Fecha de creación del documento: {0} <br>Tipo de Documento: {1} <br>Mensaje de Error: {2} <br>" +
"ID del documento: {3} <br>Intentos de Sincronización: {4} <br>",
InventoryOffline_Model.DateE,
docName,
InventoryOffline_Model.MessageSync,
InventoryOffline_Model.OfflineDocumentId,
InventoryOffline_Model.Retry);
emailBody.AppendLine(block);
///sending a block of code, this will happen n# times as i might send several items or just 1
}
THelperSendMail.SendGrid("MyCompanyEmail.com",
SendTo, //got this from appsetings
"Alertas de sincronización",
emailBody.ToString(),//taking the block as text. maybe this is the mistake?
"My Company",
true);
if (THelperSendMail.Error)
{
_oResp.SendError(-248, "Ha ocurrido un error en el envío de correo electrónico");
}
else
{
_oResp.SendResponse(message: "");
}
使用 HTML 文件作为正文发送电子邮件
电子邮件以纯文本形式发送
HTML 文件永远不会被使用或在发送电子邮件时被重写
答: 暂无答案
评论
template