Solved

Which email code should I use?

Posted on 2012-03-26
7
280 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
Comment Utility
System.Net.Mail is easier to use than System.Web.Mail in most circumstances.  Both rely on having access to SMTP server.
0
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 150 total points
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:jdhackett
Comment Utility
System.Web.Mail it is then. Thanks.
0
 
LVL 74

Expert Comment

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

Assisted Solution

by:alrosmarz
alrosmarz earned 200 total points
Comment Utility
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
Comment Utility
Sorry, meant to say "System.Net.Mail it is then"!
Thanks all for the help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now