Jumpercables
Apr 30th, 2006, 05:36 PM
I am trying to write a class to read email from a pop3 server and I am trying to read information from my gmail account. But everytime I get to the line indicated I get the following error I am not sure how to combat this problem.
"Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host."
Here is the code I am trying to make the initial connection.
Private _Server As TcpClient
Private _NetStrm As NetworkStream
Private _ReadStrm As StreamReader
Private _IncommingData As Byte()
Private _Password as String
Private _Username as String
Private Const CRLF As String = vbCrLf
Public Function Connect() As Boolean
' create server POP3 with port 110
_Server = New TcpClient("pop.gmail.com", 110)
Try
_NetStrm = _Server.GetStream()
_ReadStrm = New StreamReader(_Server.GetStream())
'Login Process
Dim Data As String = "USER " & _Username & CRLF
_IncommingData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
_NetStrm.Write(_IncommingData, 0, _IncommingData.Length)
Data = "PASS " & _Password & CRLF
_IncommingData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
_NetStrm.Write(_IncommingData, 0, _IncommingData.Length)'Error Here
'Send STAT command to get information ie: number of mail and size
Data = "STAT" + CRLF
_IncommingData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
_NetStrm.Write(_IncommingData, 0, _IncommingData.Length)
Catch ex As Exception
Return False
End Try
Return True
End Function
Thanks In Advance
"Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host."
Here is the code I am trying to make the initial connection.
Private _Server As TcpClient
Private _NetStrm As NetworkStream
Private _ReadStrm As StreamReader
Private _IncommingData As Byte()
Private _Password as String
Private _Username as String
Private Const CRLF As String = vbCrLf
Public Function Connect() As Boolean
' create server POP3 with port 110
_Server = New TcpClient("pop.gmail.com", 110)
Try
_NetStrm = _Server.GetStream()
_ReadStrm = New StreamReader(_Server.GetStream())
'Login Process
Dim Data As String = "USER " & _Username & CRLF
_IncommingData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
_NetStrm.Write(_IncommingData, 0, _IncommingData.Length)
Data = "PASS " & _Password & CRLF
_IncommingData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
_NetStrm.Write(_IncommingData, 0, _IncommingData.Length)'Error Here
'Send STAT command to get information ie: number of mail and size
Data = "STAT" + CRLF
_IncommingData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray())
_NetStrm.Write(_IncommingData, 0, _IncommingData.Length)
Catch ex As Exception
Return False
End Try
Return True
End Function
Thanks In Advance