Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2005

Tip: Looking for answers? Try searching our database.

'System.Web.Mail.SmtpMail' is obsolete

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michelle - 29 Dec 2005 23:25 GMT
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 = "eMail@server.com"
Dim strFrom As String = "infoRequest@server.com"
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
Kevin Spencer - 29 Dec 2005 23:39 GMT
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

Signature

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.

> Hi...
>
[quoted text clipped - 26 lines]
>
> Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.