0
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
當我運行這個它第一次完美的作品,但是當我嘗試運行它第二次W/O關閉應用程序,它給了我40009錯誤。我想在即將連接之前發送數據。有沒有辦法查看winsock是否連接?財產以後像Winsock錯誤40009 VB6
如果winsock1.state = true,那麼...
我該如何去做,有沒有像 – gary
如果你可以發佈更多的代碼,協助會更容易。但一般情況下,您需要等到連接完成後才能進行I/O操作。發生這種情況時有一個Connect事件通知您。 – tcarvin