Here is sample for sending Authenticated emails.
private void SendMail()
{
try
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("vinothnat@hotmail.com", "Vinothkumar");
mail.To.Add(new MailAddress("vinoth_nat@hotmail.com", "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;
smtp.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
...S.VinothkumaR.
1 comment:
your posts are awesome buddy thanks for sharing your works with us
cheers :)
Post a Comment