Powered By Blogger

Thursday, November 8, 2012

Code for sending mail to client using smtp namespace.

         using System.Net.Mail;
       method ()
     {
       -----------
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            MailMessage mm = new MailMessage("111@gmail.com", "222@gmail.com");
            mm.Subject = "Application Status";
            mm.IsBodyHtml = true;
            mm.Body = "<span>Hi.!.I am sending mail.</span>" ;
            SmtpClient client = new SmtpClient();
            smtp.Credentials = new System.Net.NetworkCredential("111@gmail.com", "Your Password");
            smtp.EnableSsl = true;
            smtp.Send(mm);
            ----
           }

No comments:

Post a Comment