DataFlex
DataFlex
Test for an IMAP Server Capability
See more IMAP Examples
Demonstrates the Chilkat Imap.HasCapability method, which tests whether a named capability appears in a raw capability response. The second argument is typically the string returned by the Capability method. This example checks whether the server supports the IDLE extension.
Background: Rather than scanning the raw
CAPABILITY text yourself, HasCapability parses it for a specific token. This is the right guard before using any optional feature — for example, only entering an IDLE wait loop, or using the MOVE command, when the server actually advertises it. Fetch the capability string once and test it as many times as needed.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
String sCapabilities
Boolean iHasIdle
String sTemp1
Boolean bTemp1
Move False To iSuccess
// Demonstrates the Imap.HasCapability method, which tests whether a named capability appears
// in a raw capability response. The 2nd argument is typically the string returned by the
// Capability method.
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
Get ComConnect Of hoImap "imap.example.com" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Get the raw capability response.
Get ComCapability Of hoImap To sCapabilities
Get ComLastMethodSuccess Of hoImap To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Test whether the server supports the IDLE extension.
Get ComHasCapability Of hoImap "IDLE" sCapabilities To iHasIdle
If (iHasIdle = True) Begin
Showln "The server supports IDLE."
End
Else Begin
Showln "The server does not support IDLE."
End
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure