How to send Authenticated Emails?

Here is sample for sending Authenticated emails.
private void SendMail()
MailMessage mail = new MailMessage();
mail.From = new MailAddress("", "Vinothkumar");
mail.To.Add(new MailAddress("", "S.Vinothkumar"));
//To property is a generic collection. So we can add as many recipients as we like
mail.Subject = "TestMail";
mail.Body = "I am testing the mail with credentials.";
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("localhost");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
NetworkCredential credential = new NetworkCredential("username", "password");
smtp.UseDefaultCredentials = false;
smtp.Credentials = credential;
catch (Exception ex)


1 comment:

Mohammed Mushtaq Ilyas said...

your posts are awesome buddy thanks for sharing your works with us
cheers :)