By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,029 Members | 1,331 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,029 IT Pros & Developers. It's quick & easy.

sending email using with C#

P: 15
In my application i am using smtp server for sending mails
i rote the host name,port in the web.config file like this
<sectionGroup name ="" >
<section name="authenticationModules" type="System.Net.Configuration.NetAuthenticationMo duleHandler"></section>
<network host ="" userName ="" password="BHaru" port ="25"/>

and i am retriving the values from the web.config to my .net application but i am getting an error for retriving the values..........

Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpC ontext.Current.Request.ApplicationPath);
MailSettingsSectionGroup settings = new MailSettingsSectionGroup();
settings = (MailSettingsSectionGroup)config.GetSectionGroup(""); // 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.Subject = txtsubject.Text;
message.IsBodyHtml = false;
message.Body = txtmessage.Text;


catch (Exception ex)

i am getting the error at settings statement

settings = (MailSettingsSectionGroup)config.GetSectionGroup("");

please help me..........
Sep 26 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.