Call IMAPISession::OpenEntry only when you do not know what kind of object you are opening. If you know you are opening a folder or a message, call IMsgStore::OpenEntry. If you know you are opening an address book container, a messaging user, or a distribution list, call IAddrBook::OpenEntry. These more specific methods are faster than IMAPISession::OpenEntry.
MAPI opens all objects with read-only access, unless you set the MAPI_MODIFY or MAPI_BEST_ACCESS flag in the ulFlags parameter. Setting one of these flags does not guarantee a particular type of access; the permissions that you are granted depends on the service provider, your access level, and the object. To determine the access level of the opened object, retrieve its PR_ACCESS_LEVEL property.
Calling OpenEntry and setting lpEntryID to point to the entry identifier of a message store is equivalent to calling the IMAPISession::OpenMsgStore method with the MDB_NO_DIALOG flag set. The flag settings are also equivalent, with the exception that to request read/write access with OpenMsgStore, you must set the MDB_WRITE flag rather than MAPI_MODIFY.
Check the value returned in the lpulObjType parameter to determine that the object type returned is what you expected. If the object type is not the type you expected, cast the pointer from the lppUnk parameter to a pointer of the appropriate type. For example, if you are opening a folder, cast lppUnk to a pointer of type LPMAPIFOLDER.