public static void SendEmail(string ReceiverEmailID, string EmailSubject, string MessageBody, string application = "") { string connectionString = ConfigurationManager.ConnectionStrings["NHSConStr"].ConnectionString; DBEngine dBEngine = new DBEngine(connectionString); WebsiteSetting setting = dBEngine.GetWebsiteSettings(0); #region Email string SMTPCLIENT = setting.SMTPServer; string EMAILID = setting.EmailID; string PASSWORD = setting.Password; int PORT = setting.Port; bool ENABLESSL = false; string EMAIL_DISPLAYNAME = "CORS"; #endregion try { MailMessage mail = new MailMessage(); string smtp = SMTPCLIENT; //ServerSettings.SMTPCLIENT; SmtpClient SmtpServer = new SmtpClient(SMTPCLIENT); //new SmtpClient(ServerSettings.SMTPCLIENT); //mail.From = new MailAddress(ServerSettings.EMAILID, ServerSettings.EMAIL_DISPLAYNAME); mail.From = new MailAddress(EMAILID, EMAIL_DISPLAYNAME); mail.To.Add(ReceiverEmailID); mail.Subject = HttpUtility.HtmlDecode(EmailSubject); String emailBody = MessageBody; mail.Body = HttpUtility.HtmlDecode(emailBody); mail.IsBodyHtml = true; //SmtpServer.Port = ServerSettings.PORT; SmtpServer.Port = PORT; //SmtpServer.Credentials = new System.Net.NetworkCredential(ServerSettings.EMAILID, ServerSettings.PASSWORD); SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential(EMAILID, PASSWORD); //SmtpServer.EnableSsl = ServerSettings.ENABLESSL; SmtpServer.EnableSsl = ENABLESSL; SmtpServer.Send(mail); } catch (Exception ex) { dBEngine.LogException(ex.Message, "HomeController", "SendEmail", System.DateTime.Now, 0); } }