Imports System. IO
Imports System. Net
Imports System. Net. Sockets
......
Private Function Connect (ByVal strServer As String, ByVal strUser As String, ByVal strPwd As String) As NetworkStream
Dim Sender As New TcpClient (strServer, 110)
Dim OutBytes As Byte ()
Dim input As String
Dim Ns As NetworkStream = Nothing
Try
Ns = Sender. GetStream ()
Dim sr As New StreamReader (Ns)
Input = "user" & strUser & vbCrLf
Outbytes = System. Text. Encoding. ASCII. GetBytes (input)
Ns. Write (OutBytes, 0, OutBytes. Length)
Console. WriteLine (sr. ReadLine ())
Input = "pass" & strPwd & vbCrLf
OutBytes = System. Text. Encoding. ASCII. GetBytes (input)
Ns. Write (OutBytes, 0, OutBytes. Length)
Console. WriteLine (sr. ReadLine ())
Console. writeLine ("========================================== ================================ ")
Return Ns
Catch ex As Exception
MsgBox ("unable to connect to server", MsgBoxStyle. Critical)
Return Ns
End Try
End Function
Private Function GetNumberOfNewMessages () As Integer
Dim OutBytes As Byte ()
Dim input As String
Dim strTemp As String
GetNumberOfNewMessages =-1
Try
Dim Ns As NetworkStream = Connect ("Enter the email server name here", "User Name", "password ")