I use the code below to send mail using yahoo smtp and ended up with error failed sending mail pl check the code and tell me where I went wrong
public void sendMail()
{
SmtpClient client = new SmtpClient();
MailMessage message = new MailMessage();
client.Port = 465;
//client.Host = "smtp.gmail.com";
client.Host = "plus.smtp.mail.yahoo.com";//"smtp.bizmail.yahoo.com";
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("abinav@yahoo.com", "MyPassword");
client.EnableSsl = true;
try
{
MailAddress SendTo = new MailAddress("mahesh@yahoo.com");
// MailAddress SendTo = new MailAddress("abinav@yahoo.com");
MailAddress SendFrom = new MailAddress("abinav@yahoo.com");
message = new MailMessage(SendFrom, SendTo);
message.Body = "Test Mail";
message.Subject = "Test Mail";
client.Send(message);
}
catch (Exception ex)
{
}
}
and the inner exception states "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." It works well with smtp.gmail.com but not with yahoo pl help me its very urgent