Sample code for 30+ languages & platforms
PureBasic

Transition from Imap.Search to Imap.QueryMbx

Provides instructions for replacing deprecated Search method calls with QueryMbx.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkImap.pb"
IncludeFile "CkMessageSet.pb"

Procedure ChilkatExample()

    success.i = 0

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

    ; ...
    ; ...

    criteria.s = "FROM bob@example.com"
    bUid.i = 1

    ; ------------------------------------------------------------------------
    ; The Search method is deprecated:

    msgSetObj.i = CkImap::ckSearch(imap,criteria,bUid)
    If CkImap::ckLastMethodSuccess(imap) = 0
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    ; ...
    ; ...

    CkMessageSet::ckDispose(msgSetObj)

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

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

    success = CkImap::ckQueryMbx(imap,criteria,bUid,mset)
    If success = 0
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        CkMessageSet::ckDispose(mset)
        ProcedureReturn
    EndIf



    CkImap::ckDispose(imap)
    CkMessageSet::ckDispose(mset)


    ProcedureReturn
EndProcedure