Sample code for 30+ languages & platforms
DataFlex

Transition from Imap.FetchChunk to Imap.FetchRange

Provides instructions for replacing deprecated FetchChunk method calls with FetchRange.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoImap
    Integer iStartSeqNum
    Integer iCount
    Variant vFailedSet
    Handle hoFailedSet
    Variant vFetchedSet
    Handle hoFetchedSet
    Variant vBundleObj
    Handle hoBundleObj
    Boolean iHeadersOnly
    Variant vBundleOut
    Handle hoBundleOut
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

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

    // ...
    // ...

    Move 1 To iStartSeqNum
    Move 5 To iCount

    Get Create (RefClass(cComChilkatMessageSet)) To hoFailedSet
    If (Not(IsComObjectCreated(hoFailedSet))) Begin
        Send CreateComObject of hoFailedSet
    End
    Get Create (RefClass(cComChilkatMessageSet)) To hoFetchedSet
    If (Not(IsComObjectCreated(hoFetchedSet))) Begin
        Send CreateComObject of hoFetchedSet
    End

    // ------------------------------------------------------------------------
    // The FetchChunk method is deprecated:

    Get pvComObject of hoFailedSet to vFailedSet
    Get pvComObject of hoFetchedSet to vFetchedSet
    Get ComFetchChunk Of hoImap iStartSeqNum iCount vFailedSet vFetchedSet To vBundleObj
    If (IsComObject(vBundleObj)) Begin
        Get Create (RefClass(cComChilkatEmailBundle)) To hoBundleObj
        Set pvComObject Of hoBundleObj To vBundleObj
    End
    Get ComLastMethodSuccess Of hoImap To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // ...
    // ...

    Send Destroy of hoBundleObj

    // ------------------------------------------------------------------------
    // Do the equivalent using FetchRange.
    // Your application creates a new, empty EmailBundle object which is passed 
    // in the last argument and filled upon success.

    Move False To iHeadersOnly

    Get Create (RefClass(cComChilkatEmailBundle)) To hoBundleOut
    If (Not(IsComObjectCreated(hoBundleOut))) Begin
        Send CreateComObject of hoBundleOut
    End
    Get pvComObject of hoBundleOut to vBundleOut
    Get ComFetchRange Of hoImap iHeadersOnly iStartSeqNum iCount vBundleOut To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End



End_Procedure