Share via


IPOutlookItemCollection::Sort

The Sort method sorts folder items based on an item property.

Syntax

HRESULT Sort(
  BSTR pwszProperty,
  VARIANT BOOL fDescending
);

Parameters

  • pwszProperty
    [in] Reference to a null-terminated Unicode string with the property on which to sort.
  • fDescending
    [in] TRUE to sort in descending order; FALSE to sort in ascending order.

Return Values

This method returns the standard values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, and E_FAIL, as well as the following:

  • S_OK
    The method completed successfully.

Remarks

The default property used to order an Items collection depends on the data type and on the Windows Mobile-based platform or version. If you require a particular sort order, specify it with the Sort method. Do not rely on the default sort order.

You cannot sort on the following properties: Categories, BodyInk, ReminderTime, and Recipients.

Example

The following code shows how to sort items in ascending order.

void SortItems(IPOutlookApp * polApp)
{
    IPOutlookItemCollection * pItems;
    IFolder * pFolder;

    // Get the contacts Items collection.
    polApp->GetDefaultFolder(olFolderContacts, &pFolder);
    pFolder->get_Items(&pItems);

    // Sort items.
    pItems->Sort(TEXT "[TimezoneIndex]", FALSE);

    // Release objects.
    pItems->Release();
    pFolder->Release();
}

Requirements

Smartphone: Windows Mobile 2002 and later
OS Versions: Windows CE 3.0 and later
Header: pimstore.h
Library: pimstore.lib

See Also

IPOutlookItemCollection

Pocket Outlook Object Model API Interfaces

Last updated on Friday, April 22, 2005

© 2005 Microsoft Corporation. All rights reserved.

Send feedback on this topic to the authors.