I am trying to check email using the winsock control. I cannot figure why the control is not connecting. It fails in the USER function that I wrote.
VB Code:
Function ReceiveMail(ws1 As Winsock, ServerName As String, ServerPort As Integer, UserName As String, Password As String) As String Dim NumMessages As Integer Dim i As Integer Dim s() As String Dim sMsg As String Set wsck = ws1 With wsck .Close If .State = sckClosed Then .LocalPort = 0 .Protocol = sckTCPProtocol .RemoteHost = ServerName .RemotePort = ServerPort RaiseEvent Sent("Connection Requested (Remote Port 110). Waiting for mResponse.") USER UserName PASS Password NumMessages = STAT(ws1) If NumMessages > 0 Then If LIST(ws1) Then For i = 1 To NumMessages sMsg = RETR(ws1, 1) Next End If End If QUIT End If .Close End With End Function Private Function USER(UserName As String) As Boolean Dim start As Single Dim tmr As Single Dim i As Integer wsck.Connect '.Connect ServerName, ServerPort ' Start connection RaiseEvent Sent("Authenticating...") 'FAILS FAILS FAILS FAILS FAILS FAILS FAILS FAILS wsck.SendData "USER " & UserName & vbCrLf start = Timer Do While Left(mResponse, 3) <> "OK+" tmr = Timer - start If tmr > 30 Then MsgBox "USER command failed" mResponse = "" USER = False Exit Function End If Loop USER = True RaiseEvent Sent("USER Successful") mResponse = "" End Function




Reply With Quote