Microsoft KB Archive/230749

= PRB: Cannot Store PR_ENTRYID in a Fixed Length Field =

Article ID: 230749

Article Last Modified on 8/25/2005

-

APPLIES TO


 * Microsoft Messaging Application Programming Interface

-



This article was previously published under Q230749



SYMPTOMS
When you encounter this problem, you have difficulty storing the PR_ENTRYID property into a fixed length field.



CAUSE
The size of an EntryID is implementation specific and not defined. Therefore, defining a fixed length field for storing a variable size EntryID, in a database for example, would be impossible.



RESOLUTION
You can use the PR_SOURCE_KEY property to calculate the PR_ENTRYID on a message or folder. Because PR_SOURCE_KEY is always a 22-byte property on Exchange Server, you can define the size of a field in the database in order to store this property. The PR_SOURCE_KEY can then be used to calculate the PR_ENTRYID through the use of the EntryIDFromSourceKey API.

For a message, you will also need the PR_SOURCE_KEY of the containing folder to calculate the message's PR_ENTRYID.

Sample Code
//Get the SourceKey on the newly created Message hr = HrGetOneProp(lpMessage, PR_SOURCE_KEY, &lpMessageSK);

//Get the SourceKey on the message's containing folder hr = HrGetOneProp(lpMessageCont, PR_SOURCE_KEY, &lpMessageFoldSK);

//Get the EntryID from the PR_SOURCE_KEYs that we just //retrieved. ULONG                  ulSizeOfEntryIDSK       = 0; LPENTRYID              lpEntryIDSK             = 0; LPEXCHANGEMANAGESTORE  lpXManageStore          = 0; ULONG                  lpulEntryIDResults      = 0;

//Get a pointer to the IExchangeManageStore Interface off the store, //through QueryInterface. hr = lpDefStore->QueryInterface(IID_IExchangeManageStore,                               (LPVOID*)&lpXManageStore);

//Run EntryIDFromSourceKey to get the message or folders EntryID hr = lpXManageStore->EntryIDFromSourceKey(lpMessageFoldSK->Value.bin.cb,                                         lpMessageFoldSK->Value.bin.lpb,                                          lpMessageSK->Value.bin.cb,                                          lpMessageSK->Value.bin.lpb,                                          &ulSizeOfEntryIDSK,                                          &lpEntryIDSK);



STATUS
This behavior is by design.



MORE INFORMATION
The PR_SOURCE_KEY property is not valid for messages and folders in Exchange Personal Message Stores(.PST).

The IExchangeManageStore(IID_IExchangeManageStore) GUID can be found in the EDKGUID.h header file.

