'System.Web.Mail.SmtpMail' is obsolete

  • Thread starter Thread starter Michelle
  • Start date Start date
M

Michelle

Hi...

I'm trying to convert a 1.1 application to 2.0. Trying to send email using
code like this:

Dim strTo As String = "(e-mail address removed)"
Dim strFrom As String = "(e-mail address removed)"
Dim strSubject As String = "An information request from" & _ClientName
Dim strBodyContent As String = BodyBuilding()
SmtpMail.SmtpServer = "localhost"
Try
SmtpMail.Send(strFrom, strTo, strSubject, strBodyContent)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

Visual Studio reports (in the Error List) this:

Warning 1 'System.Web.Mail.SmtpMail' is obsolete: 'The recommended
alternative is System.Net.Mail.SmtpClient.

The method in my code above worked beautifully in 1.1. Questions:

1) why the change in 2.0

and

2) how should I use System.Net.Mail.SmtpClient to send email?

Thanks
 
Hi Michelle,

The System.Web.Mail.SmtpMail class was basically a wrapper for CDOSYS. The
new System.Net.Mail.SmtpClient is fully .Net, nicely architected, fairly
easy to use, and highly configurable. You will be glad you used it.

You can read more about how to use it at:

http://www.codeproject.com/useritems/EmailApplication.asp
http://steve.emxsoftware.com/SystemWebSmtpMail+becomes+SystemNetMailSmtpClient

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
Back
Top