Search code examples
c#wpfyahoo-mail

How to send mail from C# WPF project with yahoo bizmail


I have developed a WPF Application from which I want to send email. But the client has yahoo bizmail as their mail vnedor. I'm using the following SMTP details. But the mail is not going.

SMPT Client: `smtp.bizmail.yahoo.com`
Port: 465

with proper credentials.

And I have set EnableSsl to true on SmtpClient object.

Here is the code:

        String FromMail = Convert.ToString(rowSettings["MailFrom"]).Trim();
        String Password = Convert.ToString(rowSettings["MailFromPassword"]).Trim();
        String Host = Convert.ToString(rowSettings["MailSMTPClient"]).Trim();
        String Port = Convert.ToString(rowSettings["MailSMTPPort"]).Trim();
        auth = new NetworkCredential(FromMail, Password);
        client = new SmtpClient(Host, Convert.ToInt32(Port));
        client.EnableSsl = true;
        client.UseDefaultCredentials = false;
        client.Credentials = auth;
        client.EnableSsl = true;
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.SendAsync(mail, null);

Following is the exception:

An exception of type 'System.Net.Mail.SmtpException' occurred in System.dll but was not handled in user code


Solution

  • I found out that the port that has to be used for smtp.bizmail.yahoo.com is 587 and not 465.