POP3Socket.ListReceived

From Xojo Documentation

Event


POP3Socket.ListReceived(List as String)

Supported for all project types and targets.

Executes when the ListMessages method is called.

Notes

The List parameter contains the message listing in the format described in RFC 1939.

A typical list is:

+OK 
1 1253
2 7801
3 534
4 6724
.
  • "+OK " indicates success
  • Each following line consists in the message number, a space and the message size
  • The final dot indicates the end of the list
  • NOTE that the end of line is normally CRLF, i.e. EndOfLine.Windows.


Sample Code

The following code parses the List and store data as an array of Pairs:

Dim theList() As Pair // Will hold the result
Dim tmp() As String // Temporary table

tmp = Split(list, EndOfLine.Windows) // Store each line in the temporary table

If tmp.Ubound < 2 Then // There is no more than 2 lines, i.e. there is nothing between the leading "+OK " and the trailing "."
// The list is empty
Return
Else // The list is not empty
// Walk through the temporary table, avoiding the first and last lines which contain no information
For i As Integer = 1 To tmp.Ubound - 1
Dim s As String
s = tmp(i)
// Append a new Pair made of the message number (before the space character) and the message size (after the space character)
theList.Append(New Pair(Val(NthField(s, " ", 1 )), Val(NthField(s, " ", 2))))
Next

// Now we're ready to process the list
For i As Integer = 0 To theList.Ubound
Dim p As Pair
p = theList(i)

// p.Left contains the message number as an integer
// p.Right contains the message size as an integer

// ... Add your code here
Next
End If