|
-
Apr 30th, 2006, 05:36 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] POP3 Email Reader
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.
VB Code:
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
-
May 1st, 2006, 07:37 PM
#2
Junior Member
Re: POP3 Email Reader
Unless they've recently changed things, GMail requires that you use a secure (SSL/TLS) connection. They also require implicit SSL and don't support the STLS command, which means it doesn't support secure connections over the standard port 110; you have to connect on port 995.
-
May 1st, 2006, 10:49 PM
#3
Thread Starter
Fanatic Member
Re: POP3 Email Reader
Hmm let me give that a wing
-
May 1st, 2006, 11:05 PM
#4
Thread Starter
Fanatic Member
Re: POP3 Email Reader
Oh that is fantastic thanks Mike
This bit of extra code made it work along with port change
VB Code:
_Strm = New Net.Security.SslStream(_Server.GetStream())
DirectCast(_Strm, Net.Security.SslStream).AuthenticateAsClient(_PopServ)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|