public static bool Send(SimpleEmailModel message, SmtpSettingsModel smtp) { var mail = new MailMessage(smtp.Sender, smtp.Sender); var client = new SmtpClient { Port = int.Parse(smtp.Port), DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(smtp.Username, smtp.Password), Host = smtp.Provider }; mail.Subject = message.Subject; mail.Body = message.Body; mail.To.Add(message.To); mail.IsBodyHtml = true; try { client.Send(mail); return(true); } catch (Exception e) { Console.WriteLine(e); } return(false); }
public void SendEmailResetPassword(string email, string tempPassword) { var message = new SimpleEmailModel { From = "SBC Nigeria", To = email, Subject = "Request password reset", Body = "Dear " + email + "," }; message.Body += "<br/><br/>"; message.Body += "You recently requested for password reset on SBC website below is a temp password"; message.Body += "<br/><br/>"; message.Body += tempPassword; message.Body += "<br/><br/>"; message.Body += "Thank You."; message.Body += "<br/><br/>"; message.Body += "Regards,<br/>"; message.Body += "SBC Team"; SmtpMail.Send(message, _smtpSettings); }