Search This Blog

Wednesday, October 20, 2010

How to send Email using Asp.net or windows Application


First Add namespace :


using System.Net.Mail;


            MailMessage mail = new MailMessage();
            mail.To.Add( Gmail-id of sender );
            mail.To.Add(Email Id of Receiver);
            mail.From = new MailAddress(Gmail-id of sender);
            mail.Subject = "Subject body";

            string Body ="Message Body";
            mail.Body = Body;

            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
            smtp.Credentials = new System.Net.NetworkCredential
                 (Gmail-id of sender,Gmail-id Password of sender);


            //Or your Smtp Email ID and Password
            smtp.EnableSsl = true;
            smtp.Send(mail);
            MessageBox.Show("your mail successfully send");



By:Ravi Chaudhari