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?
SameerJagdaleConnect With a Mentor Commented:
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

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

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
rendaduiyanConnect With a Mentor Commented:
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
gdupadhyayConnect With a Mentor Commented:
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.
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.