Sample code for 30+ languages & platforms
Unicode C++

Transition from Imap.Sort to Imap.QueryMbx

Provides instructions for replacing deprecated Sort method calls with QueryMbx.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkImapW.h>
#include <CkMessageSetW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkImapW imap;

    //  ...
    //  ...

    const wchar_t *searchCriteria = L"FROM bob@example.com";
    bool bUid = true;
    const wchar_t *sortCriteria = L"DATE SUBJECT";

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

    CkMessageSetW *msgSetObj = imap.Sort(sortCriteria,L"UTF-8",searchCriteria,bUid);
    if (imap.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",imap.lastErrorText());
        return;
    }

    //  ...
    //  ...

    delete 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.
    imap.put_SortCriteria(L"DATE SUBJECT");
    imap.put_SearchCharset(L"UTF-8");

    CkMessageSetW mset;
    success = imap.QueryMbx(searchCriteria,bUid,mset);
    if (success == false) {
        wprintf(L"%s\n",imap.lastErrorText());
        return;
    }
    }