Asp.Net 2.0 Net.Mail. I don't know what else to try. Thanks.
-
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: 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
-
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: 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
-
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: 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
-
If it is embedded, find the following in your config file and change it to this see if that works.
-
I added spaces, so it will be displayed. If it is embedded, find the following in your config file < configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" > and change it to this < configuration > see if that works.
-
I added spaces, so it will be displayed. If it is embedded, find the following in your config file < configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" > and change it to this < configuration > see if that works.
I solved it this way: ' Create and define the SMTP client Dim smtpClient As New System.Net.Mail.SmtpClient ' Create access to configuration file Dim configurationFile As Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/Web.Config") ' Create mail settings section group Dim mailSettings As System.Net.Configuration.MailSettingsSectionGroup = configurationFile.GetSectionGroup("system.net/mailSettings") ' Define smtp client properties If Not mailSettings Is Nothing Then With smtpClient .Port = mailSettings.Smtp.Network.Port .Host = mailSettings.Smtp.Network.Host .Credentials = New System.Net.NetworkCredential(mailSettings.Smtp.Network.UserName, mailSettings.Smtp.Network.Password) End With End If Thanks, Miguel