This is a code that connects to gmail, passes my username and password then retrieve the response. It seems to be working fine but the problem is the response. I was instructed that the response should be like "+OK" or "-Err", instead it shows weird characters. A fellow told me that there must be a problem with the encoding... So here it is... please help me...

This is my code:

Dim _server As TcpClient
Dim _netstream As NetworkStream
Dim _stmreader As StreamReader
Dim _senddata() As Byte
Dim _ssl As Net.Security.SslStream
Dim _user, _password As String

_server = New TcpClient("", 995)
_netstream = _server.GetStream
_ssl = New Net.Security.SslStream(_server.GetStream())
DirectCast(_ssl, Net.Security.SslStream).AuthenticateAsClient("")
_stmreader = New StreamReader(_server.GetStream)
Catch _ex As Exception
Exit Sub
End Try

_user = ""
_password = "password"

_senddata = System.Text.Encoding.ASCII.GetBytes(("USER" + _user.Trim + vbCrLf).ToCharArray())
_netstream.Write(_senddata, 0, _senddata.Length)
_senddata = System.Text.Encoding.ASCII.GetBytes(("PASS" + _password.Trim + vbCrLf).ToCharArray())
_netstream.Write(_senddata, 0, _senddata.Length)
_senddata = System.Text.Encoding.ASCII.GetBytes(("STAT" + vbCrLf).ToCharArray())
_netstream.Write(_senddata, 0, _senddata.Length)

I'm using Visual Studio 2008 on Windows 7 Ultimate...