简体   繁体   English

无法使用vb.net发送Yahoo电子邮件

[英]cannot send yahoo email using vb.net

I'm working with a program that can send email supporting yahoo mail and gmail. 我正在使用可以发送支持yahoo邮件和gmail的电子邮件的程序。 And it works in gmail(if the sender utilizes gmail) But it won't work if the sender is using yahoo mail. 它可以在gmail中使用(如果发件人使用gmail),但是如果发件人使用yahoo邮件则无法使用。 Here is my code: 这是我的代码:

    mail.From = New MailAddress(TextBox2.Text)
    mail.To.Add(New MailAddress(TextBox1.Text))
    mail.Subject = TextBox4.Text
    mail.Body = TextBox4.Text



    mail.IsBodyHtml = True

    Dim client2 As SmtpClient = New SmtpClient("smtp.mail.yahoo.com", 25)
    Dim client As SmtpClient = New SmtpClient("smtp.gmail.com", 587)




    client.EnableSsl = True
    client.Credentials = New System.Net.NetworkCredential(TextBox2.Text, TextBox3.Text)


    Try
        client.Send(mail)
    Catch ex As Exception
        MessageBox.Show("Sending email failed. Please Try again")

Looks like you might be using the wrong port ? 看起来您可能使用了错误的端口 Try this 尝试这个

Dim client2 As SmtpClient = New SmtpClient("smtp.mail.yahoo.com", 587)

EDIT OK, that didn't work. 编辑好,那没有用。 Actually, isn't the SMTP address also wrong? 其实SMTP地址不是吗?

Dim client2 As SmtpClient = New SmtpClient("plus.smtp.mail.yahoo.com", 587)

You could also wrap the whole program in a Try block and catch any SmtpException and write out the special SmtpStatusCode : 您还可以将整个程序包装在Try块中,并捕获任何SmtpException并写出特殊的SmtpStatusCode

Try 
  ' Blah blah '
Catch (SmtpException e)
   Console.WriteLine("Error: {0} {1}", e.StatusCode, e.ToString) 
End Try

雅虎将465端口用于非付费用户(订阅服务)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM