views:

31

answers:

2

I was using the following code in order to send e-mails to my company's intranet accounts from a VB.NET 2003 aplication. However this code was marked as no longer valid when I migrated the application after installing Visual Studio 2005. Could you help me modifying this code in order for my application to compile succesfully?

Dim email As New System.Web.Mail.MailMessage

email.To = "some@Email"   
email.From = "my_Application" 
email.Subject = "BE CAREFULL! Errors encountered"
email.Body = "messagebody"
email.BodyFormat = Web.Mail.MailFormat.Text
System.Web.Mail.SmtpMail.SmtpServer = "###.###.###.###" 
Try
    System.Web.Mail.SmtpMail.Send(email)
Catch ehttp As System.Web.HttpException
    Console.WriteLine(ehttp.InnerException.InnerException.Message)
End Try
+1  A: 

The namespace you should be using is .. using System.Net.Mail;

bleeeah
Thanks a lot, I'll give it a try
+1  A: 

If I remember right, the jump from vs2003 to vs2005 also jumped from .net1.1 to .net2. Which means System.Web.Mail.MailMessage was marked as obsolete. .net 2.0 has System.net.mail.smtpcleint which works about the same but has the added benefit of being more Object Orientated.

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient%28VS.80%29.aspx

Tony
Thank you, The resto of the code is similar? (it seems that I am not able to vote up too)