S
shapper
Hello,
I am trying to send an email from a form in my web page.
I have the following codes:
...
Dim mailSettings As New
System.Net.Configuration.MailSettingsSectionGroup
Dim smtpClient As New System.Net.Mail.SmtpClient
smtpClient.Host = mailSettings.Smtp.Network.Host
smtpClient.UseDefaultCredentials = False
smtpClient.Port = mailSettings.Smtp.Network.Port
smtpClient.DeliveryMethod =
System.Net.Mail.SmtpDeliveryMethod.Network
smtpClient.Credentials = New
System.Net.NetworkCredential(mailSettings.Smtp.Network.UserName,
mailSettings.Smtp.Network.Password)
smtpClient.Send(message)
...
And in my Web.Config file I have:
<system.net>
<mailSettings>
<smtp deliveryMethod = "network">
<network defaultCredentials = "true"
host = "mail.domain.com"
password = "secret"
port = "25"
userName = "(e-mail address removed)" />
</smtp>
</mailSettings>
</system.net>
I am getting the error:
"ConfigurationSectionGroup cannot be edited before being added to a
section group belonging to an instance of class Configuration"
I looked for a solution all day and I can't solve this.
Could someone tell me what am I doing wrong here?
Thanks,
Miguel
I am trying to send an email from a form in my web page.
I have the following codes:
...
Dim mailSettings As New
System.Net.Configuration.MailSettingsSectionGroup
Dim smtpClient As New System.Net.Mail.SmtpClient
smtpClient.Host = mailSettings.Smtp.Network.Host
smtpClient.UseDefaultCredentials = False
smtpClient.Port = mailSettings.Smtp.Network.Port
smtpClient.DeliveryMethod =
System.Net.Mail.SmtpDeliveryMethod.Network
smtpClient.Credentials = New
System.Net.NetworkCredential(mailSettings.Smtp.Network.UserName,
mailSettings.Smtp.Network.Password)
smtpClient.Send(message)
...
And in my Web.Config file I have:
<system.net>
<mailSettings>
<smtp deliveryMethod = "network">
<network defaultCredentials = "true"
host = "mail.domain.com"
password = "secret"
port = "25"
userName = "(e-mail address removed)" />
</smtp>
</mailSettings>
</system.net>
I am getting the error:
"ConfigurationSectionGroup cannot be edited before being added to a
section group belonging to an instance of class Configuration"
I looked for a solution all day and I can't solve this.
Could someone tell me what am I doing wrong here?
Thanks,
Miguel