Winsock1.Connect "mail.website.com", 110
Do Until received: DoEvents: Loop
If sckError Then MsgBox "An error occured trying to connect to server": Exit Sub
sendMsg "USER username" ' Send UserName
If sckError Then MsgBox "Error with username": Exit Sub
sendMsg "PASS password" ' Send Password
If sckError Then MsgBox "Error with password": Exit Sub
' Get Number of Messages and total size in bytes
sendMsg "STAT"
x = InStr(Message$, " "): b = InStrRev(Message$, " ")
messages = Val(Mid$(Message$, x + 1, b - x))
Size = Val(Mid$(Message$, b + 1))
If messages = "0" Then
MsgBox "no new messages"
GoTo l
End If
For a = 1 To messages
Winsock1.Tag = "RETR"
Open "C:\Windows\Temp\eMail-" & a & ".eml" For Binary Access Write As #1
sendMsg "RETR " & a
List1.AddItem "eMail-" & a & ".eml"
Next
Winsock1.Tag = ""
Next
l:
Winsock.Close
When i run this the first time it works perfectly, but when i try to run it a second time w/o closing the app, it gives me the 40009 error. I'm thinking im trying to send data before its connected. is there a way to see if winsock is connected? somthing like
if winsock1.state = true then...