0
I am making a form that sends an email to the customer, this email comes from a template depending on the client’s stage. Ex: Estágio 01 envio o e-mail com a body vindo do modelo_01.html, se o cliente está no estágio 04, envio o e-mail com o modelo_04.html
I’m doing a format that works, but as MVC is new to me, sometimes I think I’m doing it in hardcore form. Sometimes there’s a simpler way and I don’t know.
Like I’m doing: Inside the view in question I create a template file_01.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<p>Prezado Cliente [Nome_Cliente],</p>
<p>Estamos lhe enviando o andamento do seu site conosco.</p>
<p>Novo status atualizado em:</p>
<p> [Mostra_EP] </p>
<p>[data]<p>
</body>
</html>
In the controller I called a library that I created that sends the email. First I read by Filesystem
var conteudo = System.IO.File.ReadAllText(Caminho);
Then replace the [Client Name],[Show_ep],[date]
conteudo = conteudo.Replace("[Nome_Cliente]", cliente.Nome);
conteudo = couteudo.Replace("[data],DateTime.Now);
In [Mostra_ep] it is a little more complex because I do a query in the database and a foreach and I’m assembling an html. After that Sending this content on:
objEmail.Body = conteudo;
Is there anything simpler? type a Partial that I call her she would already return me an html already ready (she executes and returns an html) because the part of [Mostra_ep] is getting giant and I haven’t even finished yet.
Search by "Asp.net template engine".
– Daniel Omine