DataFlex
DataFlex
Load a MessageSet from a Compact String
See more IMAP Examples
Demonstrates the Chilkat MessageSet.FromCompactString method, which clears the set and loads message identifiers from compact IMAP message-set syntax. The only argument is the compact string: a colon specifies an inclusive ascending range, and commas separate values or ranges. This example loads 1:5,8:10 and prints the result as a comma-separated list.
Background: Compact message-set syntax is how IMAP itself expresses groups of messages —
1:5,8:10 is far more concise than listing every id. FromCompactString is the inverse of ToCompactString: it parses that text into a set you can pass to Imap methods. Duplicates are removed, identifiers are sorted ascending, and the existing HasUids setting is preserved. Note the string carries only the numbers — it does not record whether they are UIDs or sequence numbers.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMsgSet
String sCsv
String sTemp1
Integer iTemp1
Move False To iSuccess
// Demonstrates the MessageSet.FromCompactString method, which loads a set of message
// identifiers from compact IMAP message-set syntax. The only argument is the compact string.
// A colon specifies an inclusive range, and commas separate values or ranges.
Get Create (RefClass(cComChilkatMessageSet)) To hoMsgSet
If (Not(IsComObjectCreated(hoMsgSet))) Begin
Send CreateComObject of hoMsgSet
End
// Load a compact message set. "1:5,8:10" expands to 1,2,3,4,5,8,9,10.
Get ComFromCompactString Of hoMsgSet "1:5,8:10" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMsgSet To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComCount Of hoMsgSet To iTemp1
Showln "Count: " iTemp1
// Show the loaded identifiers in comma-separated form.
Get ComToCommaSeparatedStr Of hoMsgSet To sCsv
Showln sCsv
End_Procedure