Sample code for 30+ languages & platforms
PureBasic

Transition from Imap.FetchSequenceAsMime to Imap.FetchSingleBd

Provides instructions for replacing deprecated FetchSequenceAsMime method calls with FetchSingleBd.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkBinData.pb"
IncludeFile "CkImap.pb"
IncludeFile "CkStringArray.pb"

Procedure ChilkatExample()

    success.i = 0

    imap.i = CkImap::ckCreate()
    If imap.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; ...
    ; ...

    startSeqNum.i = 1
    count.i = 5

    ; ------------------------------------------------------------------------
    ; The FetchSequenceAsMime method is deprecated:

    sa.i = CkImap::ckFetchSequenceAsMime(imap,startSeqNum,count)
    If CkImap::ckLastMethodSuccess(imap) = 0
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    ; ...
    ; ...

    CkStringArray::ckDispose(sa)

    ; ------------------------------------------------------------------------
    ; Do the equivalent using FetchSingleBd.

    CkImap::setCkAutoDownloadAttachments(imap, 1)

    success = 0
    bdMime.i = CkBinData::ckCreate()
    If bdMime.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    bUid.i = 0
    i.i = 0
    While i < count
        success = CkImap::ckFetchSingleBd(imap,startSeqNum + i,bUid,bdMime)
        ; ...
        ; ...

        i = i + 1
    Wend


    CkImap::ckDispose(imap)
    CkBinData::ckDispose(bdMime)


    ProcedureReturn
EndProcedure