How to do that if there is any error (anyone) to capture this error and write to a log ..
Recently a client changed the password webmaster (email used to authenticate messages sent) And this meant that the system was no longer able to send emails. The problem is that the error was not discovered days later.
Would you like a way to catch this error and save the message (email) and a log error, how?
In controller
new MailController(_subsidiaryService).PedidoOrcamentoEmail(model).DeliverAsync();
in MailController
public EmailResult PedidoOrcamentoEmail(BudgetViewModel model)
{
From = string.Format("{0} <{1}>", model.Name, model.Email);
To.Add("Site <" + ConfigurationManager.AppSettings["toEmail"] + ">");
var subInfo = (from s in _subsidiaryService.Repository.Query()
where s.ID == model.SubsidiaryID
select new
{
s.Title,
s.District
}).SingleOrDefault();
ViewData["SubsidiaryTitle"] = subInfo.Title;
ViewData["SubsidiaryDistrict"] = subInfo.District;
Subject = "[Pedido de Orçamento] " + model.Name;
return Email("PedidoOrcamentoEmail", model);
}
protected override void OnException(System.Web.Mvc.ExceptionContext filterContext)
{
// This is not executed
base.OnException(filterContext);
}
As a test, I put in an invalid password email webmaster (used for shipping)