Wednesday, December 25, 2013

Send mail using gmail

        SmtpClient smtpclient = new SmtpClient();
        smtpclient.Host = "smtp.gmail.com";
        smtpclient.Port = 587;
        MailMessage mail = new MailMessage();
        mail.IsBodyHtml = true;
        mail.Body = "Your email body ";
        mail.From = new MailAddress("your email address");
        mail.To.Add("To email address");
        mail.Subject = "Subject";
        smtpclient.EnableSsl = true;
        smtpclient.Credentials = new NetworkCredential("youremailID@gmail.com","password");
        smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
        smtpclient.Send(mail);