Showing posts with label Email through Smtp Client. Show all posts
Showing posts with label Email through Smtp Client. Show all posts

Sunday, December 27, 2009

Send Email through Smtp Client

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com", 587);

mail.From = new MailAddress("from@xyz.com");
mail.To.Add("to@asd.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;

SmtpServer.Credentials = new System.Net.NetworkCredential("userid", "pwd");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);