Plus notice the Async versions of the Send method. So you can have many email sends going at the same time. SmtpClient is not a static class like SmtpMail was. Public void SendAsync( string from, string recipients, string subject, string body, object userToken)
Public void SendAsync( MailMessage message, object userToken) Public void Send( string from, string recipients, string subject, string body)
Public event SendCompletedEventHandler SendCompleted Throw new PlatformNotSupportedException ( SR. Public static void Send( MailMessage message) Take a look at what the send on the old one did: If you needed to do a lot of email processing it would totally suck. It’s also worth noting that the old was single threaded. Now I can have it drop the messages in a temp folder when I’m developing and have the production web.config relay the email through the main email server. You can control how it sends the email with the web/app.config like this: SmtpMail.SmtpServer = ConfigurationSettings.AppSettings Īll you have to do to convert is change your using statement from to and use and instance of SmtpClient class rather than the static SmtpMail class:
you can set the relay server in code like this: Well, this turned out to be a brain dead simple thing to convert and in the end it works even better. You could write your own code to set the relay server most likely reading the setting from your web.config’s appSettings.Īfter upgrading a web project to ASP.NET 2.0 I noticed several warnings about being obsolete and I should use. In our case we configured the smart host to route the mail through our exchange server.
So in a web farm we would configure the smtp service to route mail to a "smarthost". It would churn out messages into the C:\InetPub\MailRoot\Pickup folder. The now obsoleted was just a wrapper around CDONTS. I discovered how great the new namespace is this weekend.