public static async Task Send(String to, String toName, String subject, String message, String fromEmail = null) { var user = UserManagment.GetUserByEmail(fromEmail); var mailMessage = _createMailMessageData(to, toName, subject, message, user); using (var smtp = new SmtpClient()) { _overrideSmtpSettings(smtp, user); smtp.SendCompleted += SmtpOnSendCompleted; await smtp.SendMailAsync(mailMessage); } }
public static async Task SendEmailWithAttach(String to, String toName, String subject, String message, List <FileAttachment> files, String fromEmail = null) { var user = UserManagment.GetUserByEmail(fromEmail); var mailMessage = _createMailMessageData(to, toName, subject, message, user, files); using (var smtp = new SmtpClient()) { _overrideSmtpSettings(smtp, user); await smtp.SendMailAsync(mailMessage); } }