Send Email by C#

I need a code for Winform application that would send email to the user within the company exchange email address. The users in company are setup with exchange in outlook. Please help if it is possible for you.

Thank you,
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.

SAMIR BHOGAYTATeam LeadCommented:
Hello, This is the example of mail sending in winform applications.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Net.Mail;

namespace YourProjectName
    public partial class feedback : Form
        public feedback()

        private void feedback_Load(object sender, EventArgs e)

        private void btnSubmit_Click(object sender, EventArgs e)
            string sTo = "";
            string sFrom = txtEmail.Text;
            string sSubject = txtName.Text;
            string sBody = txtHow.Text;

                MailMessage mail = new MailMessage(sFrom, sTo, sSubject, sBody);
                SmtpClient client = new SmtpClient(""); //Your smtpclient
                MessageBox.Show("Mail Successfully Sent");
                txtName.Text = "";
                txtEmail.Text = "";
                txtContactNo.Text = "";
                txtHow.Text = "";
            catch (Exception)
                MessageBox.Show("Mail Sending Fail");

You also require to add this into app.config file of your project. The host name will be in your outlook account.

                        <network host="" port="25" userName="" password=""/>

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
pauledwardianAuthor Commented:
Can the username and password gets generated either by taking the username and password from the windows login (that user uses to login to his computer) or by prompting for a username and password for the user to input his credentials.
Basically I need to have my application install on each Users computer and then have the program to automatically send that particular user an email address like a reminder.
SAMIR BHOGAYTATeam LeadCommented:
Respected Sir,

Can you give me some time for this solution, I will give you a answer as early as possible. Thank you for reply me.
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

nishant joshiTechnology Development ConsultantCommented:
good code by @samir

add only one line,

client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
pauledwardianAuthor Commented:
Sure, take your time. :)
Thanks  nishantcomp2512 for your suggestion by the way.
pauledwardianAuthor Commented:
Hello Samir,

Thanks for helping me on this question. I was just checking to see if you could find the solution.

Nitesh LuharukaDirectorCommented:
@paul, yes you can always take the username and password from winform application instead of app.config file.
pauledwardianAuthor Commented:
Thanks guys for the help.
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.