Sample code for 30+ languages & platforms
DataFlex

Find the "Sent" IMAP Mailbox

See more IMAP Examples

Find the "Sent" IMAP mailbox. Also finds the Junk and Trash mailboxes..

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoImap
    String sRefName
    String sWildcardedMailbox
    Boolean iSubscribed
    Variant vMboxes
    Handle hoMboxes
    Integer i
    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

    Set ComSsl Of hoImap To True
    Set ComPort Of hoImap To 993
    Get ComConnect Of hoImap "imap.yourmailserver.com" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Login or authenticate in some way..
    Get ComLogin Of hoImap "your_login" "your_password" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Get the list of mailboxes.
    Move "" To sRefName
    Move "*" To sWildcardedMailbox
    Move False To iSubscribed

    Get Create (RefClass(cComChilkatMailboxes)) To hoMboxes
    If (Not(IsComObjectCreated(hoMboxes))) Begin
        Send CreateComObject of hoMboxes
    End
    Get pvComObject of hoMboxes to vMboxes
    Get ComMbxList Of hoImap iSubscribed sRefName sWildcardedMailbox vMboxes To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // The mailbox with the "/Sent" flag is the "Sent" mailbox.
    // Likewise for Junk and Trash..
    Move 0 To i
    While (i < (ComCount(hoMboxes)))
        Get ComHasFlag Of hoMboxes i "\Sent" To bTemp1
        If (bTemp1 = True) Begin
            Get ComGetName Of hoMboxes i To sTemp1
            Showln "Sent mailbox: " sTemp1
        End

        Get ComHasFlag Of hoMboxes i "\Junk" To bTemp1
        If (bTemp1 = True) Begin
            Get ComGetName Of hoMboxes i To sTemp1
            Showln "Junk mailbox: " sTemp1
        End

        Get ComHasFlag Of hoMboxes i "\Trash" To bTemp1
        If (bTemp1 = True) Begin
            Get ComGetName Of hoMboxes i To sTemp1
            Showln "Trash mailbox: " sTemp1
        End

        Move (i + 1) To i
    Loop

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


End_Procedure