Last modified: July 23, 2011

Applies to: Outlook

Opens an object in the container, returning an interface pointer for further access.

HRESULT OpenEntry(
  ULONG cbEntryID,
  LPCIID lpInterface,
  ULONG ulFlags,
  ULONG FAR * lpulObjType,


[in] The byte count in the entry identifier pointed to by the lpEntryID parameter.


[in] A pointer to the entry identifier of the object to open. If lpEntryID is set to NULL, the top-level container in the container's hierarchy is opened.


[in] A pointer to the interface identifier (IID) that represents the interface to be used to access the object. Passing NULL results in the identifier for the object's standard interface being returned. For messages, the standard interface is IMAPIMessageSite : IUnknown; for folders, it is IMAPIFolder : IMAPIContainer. The standard interfaces for address book objects are IDistList : IMAPIContainer for a distribution list and IMailUser : IMAPIProp for a messaging user.


[in] A bitmask of flags that controls how the object is opened. The following flags can be set:


Requests that the object will be opened with the maximum network permissions allowed for the user and the maximum client application access. For example, if the client has read/write permission, the object should be opened with read/write permission; if the client has read-only access, the object should be opened with read-only access.


Allows OpenEntry to return successfully, possibly before the object is fully available to the calling client. If the object is not available, making a subsequent object call can raise an error.


Requests read/write permission. By default, objects are opened with read-only access, and clients should not work on the assumption that read/write permission has been granted.


Shows items that are currently marked as soft deleted—that is, they are in the deleted item retention time phase.


[out] A pointer to the opened object's type.


[out] A pointer to a pointer to the interface implementation to use to access the open object.


The object was successfully opened.


Either the user has insufficient permissions to open the object or an attempt was made to open a read-only object with read/write permission.


The entry identifier specified by lpEntryID does not represent an object.


The entry identifier in the lpEntryID parameter is not of a format recognized by the container.

The IMAPIContainer::OpenEntry method opens an object throughout a container and returns a pointer to an interface implementation to use for further access.

Because service providers are not required to return an interface implementation of the type specified by the interface identifier in the lpInterface parameter, check the value pointed to by the lpulObjType parameter. If necessary, cast the pointer returned in lppUnk to a pointer of the appropriate type.

By default, service providers open objects with read-only access unless you set either the MAPI_MODIFY or MAPI_BEST_ACCESS flag. When one of these flags is set, service providers attempt to return a modifiable object. However, do not assume that because you requested a modifiable object that the opened object has read/write permission. Either plan for the chance of a subsequent modification to fail or retrieve the object's PR_ACCESS_LEVEL property to determine the access level granted by OpenEntry.