.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> XML >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Mail on Window Application

Posted By:krishana singh       Posted Date: December 09, 2010    Points: 15    Category: XML    URL: http://www.dotnetspark.com  

Mail on Window Application
 

using System.Net.Mail;

  private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage message = new MailMessage(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text);
                SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text);
                System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(txtSMTPUser.Text, txtSMTPPass.Text);
                emailClient.UseDefaultCredentials = false;
                emailClient.Credentials = SMTPUserInfo;
                emailClient.Send(message);
                litStatus.Text = "Message Sent";
            }
            catch (Exception ex)
            {
                litStatus.Text = ex.ToString();
            }
        }

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend