Sample code for 30+ languages & platforms
C

Transition from Imap.Sort to Imap.QueryMbx

Provides instructions for replacing deprecated Sort method calls with QueryMbx.

Chilkat C Downloads

C
#include <C_CkImap.h>
#include <C_CkMessageSet.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkImap imap;
    const char *searchCriteria;
    BOOL bUid;
    const char *sortCriteria;
    HCkMessageSet msgSetObj;
    HCkMessageSet mset;

    success = FALSE;

    imap = CkImap_Create();

    //  ...
    //  ...

    searchCriteria = "FROM bob@example.com";
    bUid = TRUE;
    sortCriteria = "DATE SUBJECT";

    //  ------------------------------------------------------------------------
    //  The Sort method is deprecated:

    msgSetObj = CkImap_Sort(imap,sortCriteria,"UTF-8",searchCriteria,bUid);
    if (CkImap_getLastMethodSuccess(imap) == FALSE) {
        printf("%s\n",CkImap_lastErrorText(imap));
        CkImap_Dispose(imap);
        return;
    }

    //  ...
    //  ...

    CkMessageSet_Dispose(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.

    //  The following properties are used instead of function arguments.
    CkImap_putSortCriteria(imap,"DATE SUBJECT");
    CkImap_putSearchCharset(imap,"UTF-8");

    mset = CkMessageSet_Create();
    success = CkImap_QueryMbx(imap,searchCriteria,bUid,mset);
    if (success == FALSE) {
        printf("%s\n",CkImap_lastErrorText(imap));
        CkImap_Dispose(imap);
        CkMessageSet_Dispose(mset);
        return;
    }



    CkImap_Dispose(imap);
    CkMessageSet_Dispose(mset);

    }