public static async Task SendCustomEmail(IncidereMailServiceModel model) { var applicationName = ConfigurationManager.AppSettings["ApplicationName"] ?? "Incidere"; var cutomEmailSubject = $"[{applicationName}] {model.EmailSubject}"; var customEmailBody = $@"Greetings {model.EmailToName}, {model.EmailCustomText1} {model.EmailCustomText2} {model.EmailCustomText3} Regards, {model.EmailFromName} [Powered by {applicationName}] "; using (var smtp = new SmtpClient()) { var mail = new MailMessage(model.EmailFrom, model.EmailTo) { Subject = cutomEmailSubject, Body = customEmailBody, IsBodyHtml = false }; await smtp.SendMailAsync(mail); } }
public static async Task SendEmail(IncidereMailServiceModel model) { using (var smtp = new SmtpClient()) { var mail = new MailMessage(model.EmailFrom, model.EmailTo) { Subject = model.EmailSubject, Body = model.EmailBody, IsBodyHtml = false }; await smtp.SendMailAsync(mail); } }