Any help that anyone can provide to my coding would be greatly appreciated here. I'm very frustrated that I can't figure this out. What am I missing or doing wrong?

Using VB 2010 Express, I have code for an AT&T email account that has worked great in the past, but since they have changed their login criteria, I have not been able to connect.

The old data was as follows:
Host: smtp.att.yahoo.com
Port: 25

The new settings are now:
Host: outbound.att.net
Port: 465
SMTP required authentication.
Server requires an encrypted connection (SSL)

Here is my code with the old data commented out and the updates applied. At the end is the error message I receive.



Imports System.Net.Mail

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("MyEmail@bellsouth.net", "password")

'SmtpServer.Port = 25 '<=== Old Port
SmtpServer.Port = 465 '<=== New Port

'SmtpServer.Host = "smtp.att.yahoo.com"'<=== Old Host
SmtpServer.Host = "outbound.att.net" '<=== New Host

SmtpServer.EnableSsl = True '<=== I added this code for new connection

mail = New MailMessage()
mail.From = New MailAddress("MyEmail@bellsouth.net")
mail.To.Add("ToSomeone@SomePlace.com")
mail.Subject = "My Test Mail"
mail.Body = "This is for testing SMTP mail using .NET"

SmtpServer.Send(mail)
MsgBox("mail sent")

Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub



When ran I get this error:

System.Net.Mail.SmtpException: Failure sending mail. - System.IO.IOExecption: Unable to read data from the transport connection: net_io_connectionclosed.
at SystemNet.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 read, Boolean readline)
at SystemNet.Mail.SmtpReplyReaderFactory.ReadLines(SmptReplyReader caller, Boolean online)
at SystemNet.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at SystemNet.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at SystemNet.Mail.SmtpClient.GetConnection()
at SystemNet.Mail.SmtpClient.Send(MailMessage message)
---End of inner exception stack trace ---
at System.Net.MailSmtpClient.Send(MailMessage message)
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\MyName\Local Settings\Application\Data\Temporary Projects\WindowsApplication1\Form1.vb:line 33