Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.0.0+

Transition from Imap.Sort to Imap.QueryMbx

Provides instructions for replacing deprecated Sort method calls with QueryMbx.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
imap: HCkImap;
searchCriteria: PWideChar;
bUid: Boolean;
sortCriteria: PWideChar;
msgSetObj: HCkMessageSet;
mset: HCkMessageSet;

begin
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) then
  begin
    Memo1.Lines.Add(CkImap__lastErrorText(imap));
    Exit;
  end;

//  ...
//  ...

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) then
  begin
    Memo1.Lines.Add(CkImap__lastErrorText(imap));
    Exit;
  end;

CkImap_Dispose(imap);
CkMessageSet_Dispose(mset);