Send Feedback

The MailSwitchToFolder function switches to a folder, and displays its contents in List-View.


HRESULT MailSwitchToFolder(
  ULONG cbEntryID


  • lpEntryID
    [in] Reference to the ENTRYID of the folder to display in listview.
  • cbEntryID
    [in] Size in bytes of the ENTRYID.

Return Values

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

  • S_OK
    The call succeeded.


Because folder names may not be unique across different accounts, the folder must be specified by ENTRYID instead of by name. If there is no folder with the specified ENTRYID, this function will return an error.

This function is synchronous. When this function returns, the specified folder is shown in list-view.

If you do not have a message store pointer, you can get an ENTRYID to pass into MailSwitchToFolder using the ICEMAPISession pointer. The IMAPISession::GetMsgStoresTable returns a list of message stores. You can use IMsgStore::GetReceiveFolder on the IMsgStore interface to get the EntryID of the Inbox associated with the message store you want. If you want another folder, query the message store for properties such as PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, and PR_IPM_SENTMAIL_ENTRYID. Alternatively, you can use MAPI methods to walk the Inbox hierarchy to child folders.


Pocket PC: Windows Mobile Version 5.0 and later
Smartphone: Windows Mobile Version 5.0 and later
OS Versions: Windows CE 5.01 and later
Header: cemapi.h
Library: cemapi.lib

See Also

MAPI Functions | Messaging | PR_ENTRYID | IMAPISession::GetMsgStoresTable

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.