hi,
In my application i am using smtp server for sending mails
i rote the host name,port in the web.config file like this
<configuration>
<configSections>
<sectionGroup name ="System.net" >
<section name="authenticationModules" type="System.Net.Configuration.NetAuthenticationMo duleHandler"></section>
</sectionGroup>
</configSections>
<system.net>
<mailSettings>
<smtp>
<network host ="mail.s2tech.net" userName ="Bhargavii@s2.net" password="BHaru" port ="25"/>
</smtp>
</mailSettings>
</system.net>
and i am retriving the values from the web.config to my .net application but i am getting an error for retriving the values..........
try
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpC ontext.Current.Request.ApplicationPath);
MailSettingsSectionGroup settings = new MailSettingsSectionGroup();
settings = (MailSettingsSectionGroup)config.GetSectionGroup(" System.net"); // here i am getting the eror
NetworkCredential credentials = new NetworkCredential();
credentials.UserName = settings.Smtp.Network.UserName;
credentials.Password = settings.Smtp.Network.Password;
smtpClient.Host = settings.Smtp.Network.Host;
smtpClient.Credentials = credentials;
message.From = new MailAddress(txtfrom.Text);
message.To.Add(txtto.Text);
message.Subject = txtsubject.Text;
message.IsBodyHtml = false;
message.Body = txtmessage.Text;
smtpClient.Send(message);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
i am getting the error at settings statement
settings = (MailSettingsSectionGroup)config.GetSectionGroup(" System.net");
please help me..........