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
Solved

Which email code should I use?

Posted on 2012-03-26
7
284 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
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 150 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 150 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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 200 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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