I usually do this:
Email Service:
public void NewScholarship(Boolean isApproved, String name, String classificationDescription, String percentage, String dateStarting, String dateEnding, String description)
{
Subject = isApproved ? "¡Beca creada!" : "No se pudo crear la beca";
var templateText = isApproved ? GetTemplateHtml("NewScholarship.html") : GetTemplateHtml("Declined.html");
templateText = isApproved ? templateText
.Replace("{Name}", name)
.Replace("{Percentage}", percentage)
.Replace("{DateStarting}", dateStarting)
.Replace("{DateEnding}", dateEnding)
.Replace("{ClassificationDescription}", classificationDescription)
:
templateText.Replace("{Name}",name)
.Replace("{Description}", description);
EmailBody = templateText;
}
Controller:
using (var emailService = new EmailsService())
{
emailService.SetRecipient(student.Email);
emailService.NewScholarship(false, student.Name, "", "", "", "", model.Description);
emailService.SetSender(user, model.WithName);
emailService.Send();
}
After this I create an HTML template to send the mail (for each type of email). But my boss told me that this is not practical. And he told me to make a table and only an html file and depending on the user's request, the template will change the parameters.
For example, I have a Recovery Password and in my Html template I call these parameters:
{Username}
{URLrecovery}
And as I said before, I usually make another Html file for my Create Account, and I call these parameters:
{Username}
{Password}
But what my boss wants is that he only make an HTML file, and manage everything from the service and / or the controller. How do I send the parameters so that my template changes depending on the action? either CreateAccount or RecoveryPassword?