public static MailSettingsSectionGroup MailAyar()
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
return(MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");
}
Response.Write("host: " + MailAyar().Smtp.Network.Host + "<br />");
Response.Write("port: " + MailAyar().Smtp.Network.Port + "<br />");
Response.Write("Username: " + MailAyar().Smtp.Network.UserName + "<br />");
Response.Write("Password: " + MailAyar().Smtp.Network.Password + "<br />");
Response.Write("from: " + MailAyar().Smtp.From + "<br />");
http://www.dotnetspider.com/forum/179482-how-get-mail-settings-from-web-config-file.aspx
Tags: