Results 1 to 4 of 4

Thread: Error Sending Email from VB. (System.Net.Mail)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2014
    Posts
    313

    Error Sending Email from VB. (System.Net.Mail)

    http://vb.net-informations.com/commu..._smtp_mail.htm

    Working on simple program that sends emails.
    This used to work.

    Error: Unable to read data from transport connection.

    Any ideas?


    Code:
    Try
                Dim SmtpServer As New SmtpClient()
                Dim mail As New MailMessage()
    
                SmtpServer.EnableSsl = True
                SmtpServer.Credentials = New System.Net.NetworkCredential("XXX@gmail.com", "XXX")
                'SmtpServer.Port = 587
                SmtpServer.Port = 465
                SmtpServer.Host = "smtp.gmail.com"
    
                mail = New MailMessage()
                mail.From = New MailAddress("XXX@gmail.com")
                mail.To.Add("XXXXXXXX@hotmail.com")
                mail.Subject = "Subj"
                mail.Body = "Body"
    
                SmtpServer.Send(mail)
    
                MsgBox("mail send")
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: Error Sending Email from VB. (System.Net.Mail)

    I Googled that using:

    vb .net Error: Unable to read data from transport connection

    and it appears there can be a variety of reasons for that. I think you will need to do the same to eliminate the various reasons if you haven't already.
    Please remember next time...elections matter!

  3. #3
    Lively Member
    Join Date
    Jan 2020
    Posts
    120

    Re: Error Sending Email from VB. (System.Net.Mail)

    This error usually means that the target machine is running, but the service that you're trying to connect to is not available. (Either it stopped, crashed, or is busy with another request.)

    In English: The connection to the machine (remote host/server/PC that the service runs at) was made but since the service was not available on that machine, the machine didn't know what to do with the request.

    If the connection to the machine was not available, you'd see a different error. I forget what it is, but it's along the lines of "Service Unreachable" or "Unavailable".

    It IS possible that this is being caused by a firewall blocking the port, but given that you say it's intermittent ("sometimes when the client tries to connect"), that's very unlikely. I didn't include that originally because I had ruled it out mentally before replying.


    Reference: link

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2014
    Posts
    313

    Re: Error Sending Email from VB. (System.Net.Mail)

    I think Google blocks the activity

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width