c# winform send mail

I am working on windowsform application. Finally this application would be installed on clients machine.
I have to integrate mail module in my application.

How can it be done. What namespaces should i import in C# . Any example.

Should the client machine have smtp server installed
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In order to send email in C# code, do the following:

// create mail message object
MailMessage mail = new MailMessage();
mail.From = "";           // put the from address here
mail.To = "";             // put to address here
mail.Subject = "";        // put subject here	
mail.Body = "";           // put body of email here
SmtpMail.SmtpServer = ""; // put smtp server you will use here 
// and then send the mail

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

dotnet0824Author Commented:
Is there any Inbuilt methods in .NET I can use???? What imports statement should i use

MailMessage mail = new MailMessage();  (Is this 3rd party) I cant find it in .NET
using System.Net.Mail;

MailAddress from = new MailAddress("xxxi@xxx.com", "xxxx");
        MailAddress to = new MailAddress("xxx@xxx.com", "xxx");
        MailMessage mail = new MailMessage(from, to);  
        foreach(ListItem li in this.DropDownList2.Items)
            MailAddress one = new MailAddress (li.Text);
            if(one.User != "xxx")
        mail.Subject = "books status updated";
        mail.Priority = MailPriority.Normal;
        mail.IsBodyHtml = false;
        mail.Body = "this mail is sent by " + Server.MachineName
            + " automatically. Please go to http:/xxx for details." 
            + Environment.NewLine
            + this.TextArea1.Value;
        SmtpClient client = new SmtpClient("sgp-sg-mb01.sgp.agilent.com");
        client.Credentials = CredentialCache.DefaultNetworkCredentials;

Open in new window

it's in .net
make sure you import the namespace,
Imports System.Net.Mail
I already give a answer of this question, but for different expert.

You can find out accepted solution on:

Please let me know, if you have any question.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

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.