Email Setting with web config
In web Config add below section
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="xxx@xxxxxxx.com">
<network defaultCredentials="false" host="Smtp.gmail.com"
password="xxxxxxx" port="25" userName="testing"/>
</smtp>
</mailSettings>
</system.net>
In Page write below code For Edit in web config.
using System.Configuration; using System.Net.Configuration; using System.Web.Configuration;
System.Configuration.Configuration config =
System.Web.Configuration.WebConfigurationManager.
OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
System.Net.Configuration.MailSettingsSectionGroup settings
= (System.Net.Configuration.MailSettingsSectionGroup)
config.GetSectionGroup("system.net/mailSettings");
settings.Smtp.Network.UserName = txtIUsername.Text.Trim();
config.Save();
