Typically, when you want to download messages from the
server, you can do it two ways:1. Connect, grab all messages, disconnect, and then
review what you got. In blocking mode, this is as easy
as:
Dim WithEvents Pop3 As
wodPop3Com
'........
Set Pop3 = New wodPop3Com
Pop3.HostName = "your.hostname.com"
Pop3.Login = "login"
Pop3.Password = "password"
Pop3.Blocking = True
Pop3.Connect
Pop3.Messages.GetAll
Pop3.Disconnect
Debug.Print
Pop3.Messages.Count
MsgBox Pop3.Messages(0).Body
2. You can connect, and then check messages one-by-one
to decide if you will download them or not. This is more
common behavior, especially on slow connections:
Option Explicit
Dim WithEvents Pop3 As
wodPop3Com
Dim Counter As Integer
Private Sub Form_Load()
Set Pop3 = New
wodPop3Com
Pop3.HostName =
"your.hostname.com"
Pop3.Login =
"login"
Pop3.Password =
"password"
Counter = 0
Pop3.Connect
End Sub
Private Sub Pop3_Connected()
Debug.Print "CONNECTED"
Debug.Print "Has
" & Pop3.Messages.Count &
" messages, download them
all"
' go with download
Pop3_Done 0,
""
End Sub
Private Sub Pop3_Disconnected(ByVal ErrorCode As
Long, ByVal ErrorText As
String)
Debug.Print "DISCONNECTED
" & ErrorText
End Sub
Private Sub Pop3_Done(ByVal
ErrorCode As Long, ByVal ErrorText
As String, HeadersOnly as Boolean)
Debug.Print "DONE
" & ErrorText
If Counter < Pop3.Messages.Count
Then
Debug.
Print "Downloading message
" & Counter & ", expected size is " &
Pop3.Messages(Counter).Size
Pop3.Messages(Counter).
Get
Counter
= Counter + 1
Else
Debug.
Print "All done.
Disconnecting..."
Pop3.Disconnect
End If
End Sub
Private Sub Pop3_Progress(ByVal Position As
Long, ByVal Total As
Long)
Debug.Print "Progress
" & Position & " / " & Total
End Sub
Private Sub Pop3_StateChange(ByVal OldState As
WODPOP3COMLib.StatesEnum)
Debug.Print "StateChange to
" & Pop3.StateText
End Sub