Results 1 to 7 of 7

Thread: Winsock Connection Error :-) ReSoLvEd

Threaded View

  1. #1

    Thread Starter
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    Question Winsock Connection Error :-) ReSoLvEd

    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:
    1. Function ReceiveMail(ws1 As Winsock, ServerName As String, ServerPort As Integer, UserName As String, Password As String) As String
    2.     Dim NumMessages As Integer
    3.     Dim i As Integer
    4.     Dim s() As String
    5.     Dim sMsg As String
    6.    
    7.     Set wsck = ws1
    8.    
    9.     With wsck
    10.         .Close
    11.         If .State = sckClosed Then
    12.             .LocalPort = 0
    13.             .Protocol = sckTCPProtocol
    14.             .RemoteHost = ServerName
    15.             .RemotePort = ServerPort
    16.             RaiseEvent Sent("Connection Requested (Remote Port 110). Waiting for mResponse.")
    17.  
    18.            
    19.             USER UserName
    20.             PASS Password
    21.            
    22.             NumMessages = STAT(ws1)
    23.            
    24.             If NumMessages > 0 Then
    25.                 If LIST(ws1) Then
    26.                     For i = 1 To NumMessages
    27.                         sMsg = RETR(ws1, 1)
    28.                     Next
    29.                 End If
    30.             End If
    31.            
    32.             QUIT
    33.         End If
    34.         .Close
    35.     End With
    36.  
    37. End Function
    38.  
    39. Private Function USER(UserName As String) As Boolean
    40.     Dim start As Single
    41.     Dim tmr As Single
    42.     Dim i As Integer
    43.    
    44.     wsck.Connect
    45.     '.Connect ServerName, ServerPort ' Start connection
    46.    
    47.     RaiseEvent Sent("Authenticating...")
    48.    
    49.    'FAILS FAILS FAILS FAILS FAILS FAILS FAILS FAILS
    50.     wsck.SendData "USER " & UserName & vbCrLf
    51.    
    52.     start = Timer
    53.     Do While Left(mResponse, 3) <> "OK+"
    54.         tmr = Timer - start
    55.         If tmr > 30 Then
    56.             MsgBox "USER command failed"
    57.             mResponse = ""
    58.             USER = False
    59.             Exit Function
    60.         End If
    61.     Loop
    62.  
    63.     USER = True
    64.     RaiseEvent Sent("USER Successful")
    65.     mResponse = ""
    66.    
    67. End Function
    Last edited by MikkyThomeon; Dec 10th, 2003 at 01:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width