Sample code for 30+ languages & platforms
DataFlex

IMAP Capability

Demonstrates how to send the CAPABILITY command to request a listing of capabilities that the IMAP server supports. A capability name which begins with "AUTH=" indicates that the server supports that particular authentication mechanism.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoImap
    String sCaps
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatImap)) To hoImap
    If (Not(IsComObjectCreated(hoImap))) Begin
        Send CreateComObject of hoImap
    End

    // Use TLS
    Set ComSsl Of hoImap To True
    Set ComPort Of hoImap To 993
    Get ComConnect Of hoImap "MY-IMAP-DOMAIN" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Authenticate
    Get ComLogin Of hoImap "MY-IMAP-LOGIN" "MY-IMAP-PASSWORD" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Get the list of capabilities:
    Get ComCapability Of hoImap To sCaps
    Showln "Capabilities: " sCaps

    // Here is an example of the string returned:
    // * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 
    // UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT APPENDLIMIT=35882577
    // LIST-EXTENDED LIST-STATUS

    // Chilkat v9.5.0.58 introduces the HasCapability method to
    // check to see if a particular capability exists:
    Get ComHasCapability Of hoImap "QUOTA" sCaps To bTemp1
    If (bTemp1 = True) Begin
        Showln "IMAP server supports the QUOTA extension."
    End

    Get ComHasCapability Of hoImap "IDLE" sCaps To bTemp1
    If (bTemp1 = True) Begin
        Showln "IMAP server supports IDLE."
    End

    // Disconnect from the IMAP server.
    Get ComDisconnect Of hoImap To iSuccess


End_Procedure