Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Which email code should I use?

Posted on 2012-03-26
7
Medium Priority
?
289 Views
Last Modified: 2012-08-13
Hi
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?
Thanks
0
Comment
Question by:jdhackett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 37766761
System.Net.Mail is easier to use than System.Web.Mail in most circumstances.  Both rely on having access to SMTP server.
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 600 total points
ID: 37766785
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.
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 600 total points
ID: 37766800
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:jdhackett
ID: 37770176
System.Web.Mail it is then. Thanks.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37770951
???   Isn't that the opposite of what everyone here said?
0
 
LVL 1

Assisted Solution

by:alrosmarz
alrosmarz earned 800 total points
ID: 37771586
i use this..

 try
            {
                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))
                    email.CC.Add(CC);
                if (!string.IsNullOrEmpty(CCO))
                    email.Bcc.Add(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());
                client.Send(email);
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
0
 
LVL 1

Author Comment

by:jdhackett
ID: 37804983
Sorry, meant to say "System.Net.Mail it is then"!
Thanks all for the help.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

671 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question