I’m working with a program that can send email supporting yahoo mail and gmail. And it works in gmail(if the sender utilizes gmail) But it won’t work if the sender is using yahoo mail.
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
EDIT
OK, that didn’t work. Actually, isn’t the SMTP address also wrong?
You could also wrap the whole program in a
Tryblock and catch anySmtpExceptionand write out the special SmtpStatusCode: