so im very new to programing and was tasked to send an email. the email gets sent. but it seems im either not using the html. or im rewriting or deleting it somehow. can someone give me a hand to understand what am i doing wrong? im annexing the piece of code that sends the email. if you require more please tell me
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: "");
}
sending an email using an html file as body
the email gets send but as plain text
the html file never gets used or is rewritten at the moment of sending the email