Which email code should I use?

My code monitors a website and then sends an email when the site is updated. I have Outlook code that can send an email.
I did some research online, and most sites recommended to use System.Web.mail instead. However, when I type
Dim oMail As New MailMessage
I get a message from Visual Studio that
'System.Web.Mail.MailMessage' is obsolete: 'The recommended alternative is System.Net.Mail.MailMessage. http://go.microsoft.com/fwlink/?linkid=14202'

Which mail library should I use?
Who is Participating?
Paul JacksonConnect With a Mentor Software EngineerCommented:
System.Web.Mail is deprecated as of .Net Framework 3.5 so you should use System.Net.Mail as support for System.Web.Mail may be dropped in a future version of the framework
System.Net.Mail is easier to use than System.Web.Mail in most circumstances.  Both rely on having access to SMTP server.
käµfm³d 👽Connect With a Mentor Commented:
Anything marked as "obsolete" generally means you should use the other. IIRC, "obsolete" items have the potential to be removed in future updates, though I don't think MS has removed anything since the change from 1.x to 2.0.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

jdhackettAuthor Commented:
System.Web.Mail it is then. Thanks.
käµfm³d 👽Commented:
???   Isn't that the opposite of what everyone here said?
alrosmarzConnect With a Mentor Commented:
i use this..

                StringBuilder emailMessage = new StringBuilder();
                System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage();
                email.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["MailFrom"].ToString());
                email.To.Add(new MailAddress(Para));
                if (!string.IsNullOrEmpty(CC))
                if (!string.IsNullOrEmpty(CCO))
                email.Subject = Subject;
                email.Body = BodyCorreo;
                email.IsBodyHtml = true;

                SmtpClient client = new SmtpClient();
                client.Port = int.Parse(System.Configuration.ConfigurationManager.AppSettings["SMTPPort"].ToString());
                client.Host = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"].ToString();
                client.Credentials = new System.Net.NetworkCredential(System.Configuration.ConfigurationManager.AppSettings       ["SMTPUser"].ToString(), System.Configuration.ConfigurationManager.AppSettings["PasswordMailFrom"].ToString());
                return true;
            catch (Exception ex)
                throw ex;
jdhackettAuthor Commented:
Sorry, meant to say "System.Net.Mail it is then"!
Thanks all for the help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.