Question : VB.NET simple SendMail program error: System.Net.Mail.SmtpException: Failure sending mail

EE Experts,

I am getting the following error message from a simple VB.NET SendMail program that I got from Francesco Balena's book "Programming Microsoft Visual Basic .NET" version 2003. Francesco's program Imports system.web.mail. I converted it to system.net.mail. I know that I am getting to the SMTP server by the content of the error message. I need to know what property to add or change to satisify the SMTP server.

************** Exception Text **************
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---

My code is attached in the code snippet.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

        Dim msg As New MailMessage
        msg.From = New MailAddress(txtFrom.Text)
        msg.To.Add(txtTo.Text)
        msg.CC.Add(txtCC.Text)
        msg.Bcc.Add(txtBCC.Text)
        msg.Priority = CType([Enum].Parse(GetType(MailPriority), cboPriority.Text), MailPriority)
        msg.Subject = txtSubject.Text
        msg.Body = txtBody.Text
        'msg.

        'If txtAttachment.Text.Length > 0 Then
        '    Dim attachment As New MailAttachment(txtAttachment.Text)
        '    msg.Attachments.Add(attachment)
        'End If
        Try
            Dim smtp As SmtpClient = New SmtpClient("smtp.att.yahoo.com")
            smtp.EnableSsl = True
            'Enter the Authentication Credentials
            Dim cred As New System.Net.NetworkCredential("********@sbcglobal.net", "********")
            smtp.Credentials = cred
            smtp.Port = 465


            smtp.Send(msg)
        Catch ex As HttpException
            MsgBox(ex.Message)
        End Try

    End Sub

Answer : VB.NET simple SendMail program error: System.Net.Mail.SmtpException: Failure sending mail

System.Net.Mail does not support "implicit" SSL, only "explicit" SSL.

This may or may not help.

http://stackoverflow.com/questions/172203/why-does-system-net-mail-fail-where-system-web-mail-works

http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx

guru_sami mentioned Google email... I have used that successfully myself.
Random Solutions  
 
programming4us programming4us