Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Asp.Net 2.0 Net.Mail. I don't know what else to try. Thanks.

Asp.Net 2.0 Net.Mail. I don't know what else to try. Thanks.

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netsysadminhelpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shapper
    wrote on last edited by
    #1

    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

    E 2 Replies Last reply
    0
    • 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: 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

      E Offline
      E Offline
      ednrgc
      wrote on last edited by
      #2

      The error is telling you to make sure it's inside the Configuration tag. Is it wrapped?

      1 Reply Last reply
      0
      • 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: 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

        E Offline
        E Offline
        ednrgc
        wrote on last edited by
        #3

        If it is embedded, find the following in your config file and change it to this see if that works.

        S 1 Reply Last reply
        0
        • E ednrgc

          If it is embedded, find the following in your config file and change it to this see if that works.

          S Offline
          S Offline
          shapper
          wrote on last edited by
          #4

          I can't see what you posted but yes it is wrapped in tags.

          E 1 Reply Last reply
          0
          • S shapper

            I can't see what you posted but yes it is wrapped in tags.

            E Offline
            E Offline
            ednrgc
            wrote on last edited by
            #5

            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.

            S 1 Reply Last reply
            0
            • E ednrgc

              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.

              S Offline
              S Offline
              shapper
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups