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. General Programming
  3. C#
  4. Email in C# 2005 (.net 2.0)

Email in C# 2005 (.net 2.0)

Scheduled Pinned Locked Moved C#
csharpquestion
8 Posts 4 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.
  • D Offline
    D Offline
    Daniel1324
    wrote on last edited by
    #1

    The System.Web class has been deprecated in .net 2.0... So the email code I've been using no longer works. After some tinkering, I got the System.Net class to send the email, however... It wont actually send the mail until I exit the program. Whats the deal with that? The function finishes with no errors. I can wait and nothing happens. Then the moment I close the program, the email leaves my machine. I know this because Norton scans outgoing emails. Anybody?

    G D 2 Replies Last reply
    0
    • D Daniel1324

      The System.Web class has been deprecated in .net 2.0... So the email code I've been using no longer works. After some tinkering, I got the System.Net class to send the email, however... It wont actually send the mail until I exit the program. Whats the deal with that? The function finishes with no errors. I can wait and nothing happens. Then the moment I close the program, the email leaves my machine. I know this because Norton scans outgoing emails. Anybody?

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      System.Web is not a class, it's a namespace. Are you sure that it's deprecated? It contains everything that has to do with asp.net, so it doesn't seem likely. Even if it were deprecated it doesn't mean that it's removed, so the code should still work. Why do you think that it doesn't work? From what you descibe of your problem, it sounds like mail is not sent until the object is collected by the garbage collector. Are you closing and disposing the objects you use properly? --- b { font-weight: normal; }

      D D 3 Replies Last reply
      0
      • G Guffa

        System.Web is not a class, it's a namespace. Are you sure that it's deprecated? It contains everything that has to do with asp.net, so it doesn't seem likely. Even if it were deprecated it doesn't mean that it's removed, so the code should still work. Why do you think that it doesn't work? From what you descibe of your problem, it sounds like mail is not sent until the object is collected by the garbage collector. Are you closing and disposing the objects you use properly? --- b { font-weight: normal; }

        D Offline
        D Offline
        David Stone
        wrote on last edited by
        #3

        System.Web.Mail and its containing classes have been deprecated in Whidbey. System.Net.Mail is the new location for some much improved e-mail classes.


        [Cheshire] I can't afford those plastic things to cover the electric sockets so I just draw bunny faces on the electric outlets to scare the kids away from them... [RLtim] Newsflash! Kids aren't afraid of bunnies. [Cheshire] Oh they will be... -Bash.org

        G 1 Reply Last reply
        0
        • D Daniel1324

          The System.Web class has been deprecated in .net 2.0... So the email code I've been using no longer works. After some tinkering, I got the System.Net class to send the email, however... It wont actually send the mail until I exit the program. Whats the deal with that? The function finishes with no errors. I can wait and nothing happens. Then the moment I close the program, the email leaves my machine. I know this because Norton scans outgoing emails. Anybody?

          D Offline
          D Offline
          David Stone
          wrote on last edited by
          #4

          Have you tried disabling Norton's e-mail scanning? I've been using the new mail classes in an app here and it works as soon as I call Send().


          [Cheshire] I can't afford those plastic things to cover the electric sockets so I just draw bunny faces on the electric outlets to scare the kids away from them... [RLtim] Newsflash! Kids aren't afraid of bunnies. [Cheshire] Oh they will be... -Bash.org

          S 1 Reply Last reply
          0
          • D David Stone

            System.Web.Mail and its containing classes have been deprecated in Whidbey. System.Net.Mail is the new location for some much improved e-mail classes.


            [Cheshire] I can't afford those plastic things to cover the electric sockets so I just draw bunny faces on the electric outlets to scare the kids away from them... [RLtim] Newsflash! Kids aren't afraid of bunnies. [Cheshire] Oh they will be... -Bash.org

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Yes, that makes much more sense. [ot] Why did they put mail in the web namespace in the first place? [/ot] --- b { font-weight: normal; }

            1 Reply Last reply
            0
            • G Guffa

              System.Web is not a class, it's a namespace. Are you sure that it's deprecated? It contains everything that has to do with asp.net, so it doesn't seem likely. Even if it were deprecated it doesn't mean that it's removed, so the code should still work. Why do you think that it doesn't work? From what you descibe of your problem, it sounds like mail is not sent until the object is collected by the garbage collector. Are you closing and disposing the objects you use properly? --- b { font-weight: normal; }

              D Offline
              D Offline
              Daniel1324
              wrote on last edited by
              #6

              Guffa wrote: From what you descibe of your problem, it sounds like mail is not sent until the object is collected by the garbage collector. Are you closing and disposing the objects you use properly? I'll look at that... thanks! I'm still new at this!

              1 Reply Last reply
              0
              • G Guffa

                System.Web is not a class, it's a namespace. Are you sure that it's deprecated? It contains everything that has to do with asp.net, so it doesn't seem likely. Even if it were deprecated it doesn't mean that it's removed, so the code should still work. Why do you think that it doesn't work? From what you descibe of your problem, it sounds like mail is not sent until the object is collected by the garbage collector. Are you closing and disposing the objects you use properly? --- b { font-weight: normal; }

                D Offline
                D Offline
                Daniel1324
                wrote on last edited by
                #7

                private void SendBill() { SmtpClient client = new SmtpClient("my.mailserver.net"); MailAddress toAddr = new MailAddress("anybody@hotmail.com"); MailAddress fromAddr = new MailAddress("test@mailserver.net"); MailMessage message = new MailMessage(fromAddr, toAddr); message.Subject = "Test Mail"; message.Body = "This is a test."; client.Send(message); } This is the code. I changed the server and addresses to post here.

                1 Reply Last reply
                0
                • D David Stone

                  Have you tried disabling Norton's e-mail scanning? I've been using the new mail classes in an app here and it works as soon as I call Send().


                  [Cheshire] I can't afford those plastic things to cover the electric sockets so I just draw bunny faces on the electric outlets to scare the kids away from them... [RLtim] Newsflash! Kids aren't afraid of bunnies. [Cheshire] Oh they will be... -Bash.org

                  S Offline
                  S Offline
                  senorbadger
                  wrote on last edited by
                  #8

                  I've had the same issue, only way round it i've found is to set the message to null and the smtp instance to null and then call GC.Collect(); MailMessage msg = new MailMessage(adminEmail, adminEmail); SmtpClient smtp = new SmtpClient(); smtp.Host = "xxx.xxx.xxx.xxx"; smtp.Port = 25; smtp.Send(msg); smtp = null; msg = null; GC.Collect();

                  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