How To Send Email Using C#

Posted by imomins on May 12, 2011 at 7:44 AM

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Net.Mail;

using System.Text.RegularExpressions;

using System.Net;

 

 

 

namespace net.ERP.Modules.Marketing.GUI.Master

{

    public partial class frmEmail : Form

    {

        public frmEmail()

        {

            InitializeComponent();

        }

       

        private void button3_Click(object sender, EventArgs e)

        {

            try

            {

 

                MailMessage mail = new MailMessage();

                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("[email protected]");

                mail.To.Add("[email protected]");

                mail.Subject = "Test Mail";

                mail.Body = "This is for testing SMTP mail from GMAIL";

                SmtpServer.Port = 587;

                SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "20121986Mominul");

                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);

                MessageBox.Show("mail Send");

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.ToString());

            }

 

        }

    }

}

 


Categories: C#, Networking, Personal

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments