当我尝试使用yahoo';s smtp服务器使用smtpclient类

当我尝试使用yahoo';s smtp服务器使用smtpclient类,smtp,smtpclient,Smtp,Smtpclient,我尝试使用smtpclient类使用yahoo的smtp服务器时出错, 我收到错误“无法从传输连接读取数据:net\u io\u connectionclosed”,这是捕获异常的内部异常: try { MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("testname@yahoo.com");

我尝试使用smtpclient类使用yahoo的smtp服务器时出错, 我收到错误“无法从传输连接读取数据:net\u io\u connectionclosed”,这是捕获异常的内部异常:

try { 
            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress("testname@yahoo.com");

            //receiver email adress
            mailMessage.To.Add("testname@yahoo.com");

            //subject of the email
            mailMessage.Subject = "This is a subject";

            mailMessage.Body = "Body of the email";
            mailMessage.IsBodyHtml = false;

            //SMTP client
            System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("smtp.mail.yahoo.com");
            //port number for Yahoo
            smtpClient.Port = 587;
            //credentials to login in to yahoo account
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = new NetworkCredential("testname@yahoo.com", "password");
            //enabled SSL
            smtpClient.EnableSsl = true;
            //Send an email
            ServicePoint sp = smtpClient.ServicePoint;
            string name = sp.ConnectionName;                
            smtpClient.Send(mailMessage);
        } catch(Exception ex)
        {
            string msg = ex.Message.ToString();
        }
我希望得到一些建议,谢谢