Friday, February 18, 2011

send a email using c# and using yahoo mail server as a SMTP server

try
{
MailMessage mm = new MailMessage("cwellage@yahoo.com","wellage@gmail.com", "test via .net", "empty");
// mm.Sender=MailAddress
SmtpClient client = new SmtpClient("smtp.mail.yahoo.com");
client.Port = 587; // this is the port of yahoo SMTP server
client.UseDefaultCredentials = false;
// client.EnableSsl = true; // make this false or comment

client.Credentials = new NetworkCredential("username","password");
client.Send(mm);

Console.WriteLine("mail send succesfully");
Console.ReadKey();

}
catch (Exception)
{

throw;
}

No comments:

Post a Comment