Email in C# 2005 (.net 2.0)
-
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?
-
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?
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; }
-
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; }
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
-
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?
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
-
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
-
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; }
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!
-
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; }
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. -
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
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();