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
<configuratio n>
<configSections >
<sectionGroup name ="System.net " >
<section name="authentic ationModules" type="System.Ne t.Configuration .NetAuthenticat ionModuleHandle r"></section>
</sectionGroup>
</configSections>
<system.net>
<mailSettings >
<smtp>
<network host ="mail.s2tech.n et" 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 = WebConfiguratio nManager.OpenWe bConfiguration( HttpContext.Cur rent.Request.Ap plicationPath);
MailSettingsSec tionGroup settings = new MailSettingsSec tionGroup();
settings = (MailSettingsSe ctionGroup)conf ig.GetSectionGr oup("System.net "); // here i am getting the eror
NetworkCredenti al credentials = new NetworkCredenti al();
credentials.Use rName = settings.Smtp.N etwork.UserName ;
credentials.Pas sword = settings.Smtp.N etwork.Password ;
smtpClient.Host = settings.Smtp.N etwork.Host;
smtpClient.Cred entials = credentials;
message.From = new MailAddress(txt from.Text);
message.To.Add( txtto.Text);
message.Subject = txtsubject.Text ;
message.IsBodyH tml = false;
message.Body = txtmessage.Text ;
smtpClient.Send (message);
}
catch (Exception ex)
{
Response.Write( ex.Message);
}
i am getting the error at settings statement
settings = (MailSettingsSe ctionGroup)conf ig.GetSectionGr oup("System.net ");
please help me..........
In my application i am using smtp server for sending mails
i rote the host name,port in the web.config file like this
<configuratio n>
<configSections >
<sectionGroup name ="System.net " >
<section name="authentic ationModules" type="System.Ne t.Configuration .NetAuthenticat ionModuleHandle r"></section>
</sectionGroup>
</configSections>
<system.net>
<mailSettings >
<smtp>
<network host ="mail.s2tech.n et" 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 = WebConfiguratio nManager.OpenWe bConfiguration( HttpContext.Cur rent.Request.Ap plicationPath);
MailSettingsSec tionGroup settings = new MailSettingsSec tionGroup();
settings = (MailSettingsSe ctionGroup)conf ig.GetSectionGr oup("System.net "); // here i am getting the eror
NetworkCredenti al credentials = new NetworkCredenti al();
credentials.Use rName = settings.Smtp.N etwork.UserName ;
credentials.Pas sword = settings.Smtp.N etwork.Password ;
smtpClient.Host = settings.Smtp.N etwork.Host;
smtpClient.Cred entials = credentials;
message.From = new MailAddress(txt from.Text);
message.To.Add( txtto.Text);
message.Subject = txtsubject.Text ;
message.IsBodyH tml = false;
message.Body = txtmessage.Text ;
smtpClient.Send (message);
}
catch (Exception ex)
{
Response.Write( ex.Message);
}
i am getting the error at settings statement
settings = (MailSettingsSe ctionGroup)conf ig.GetSectionGr oup("System.net ");
please help me..........