Algorithm to Encode Entry IDs and Attachment IDs

Algorithm to Encode Entry IDs and Attachment IDs

A store provider can send as part of a MAPI Uniform Resource Locator (URL) an entry ID and an attachment ID to the MAPI Protocol Handler to identify an object that is ready for indexing. The store provider encodes the entry ID and attachment ID as Unicode strings. This topic shows an algorithm that generates a compact representation of the entry ID or attachment ID.

  const WORD kwBaseOffset = 0xAC00;  // Hangul char range (AC00-D7AF)
LPWSTR EncodeID(ULONG cbEID, LPENTRYID rgbID)
{
    ULONG   i = 0;
    LPWSTR  pwzDst = NULL;
    LPBYTE  pbSrc = NULL;
    LPWSTR  pwzIDEncoded = NULL;
// rgbID is the item Entry ID or the attachment ID
// cbID is the size in bytes of rgbID

// Allocate memory for pwzIDEncoded
pwzIDEncoded = new WCHAR[cbEID];
if (!pwzIDEncoded) return NULL;

for (i = 0, pbSrc = (LPBYTE)rgbID, pwzDst = pwzIDEncoded;
    i < cbEID;
    i++, pbSrc++, pwzDst++)
{
    *pwzDst = (WCHAR) (*pbSrc + kwBaseOffset);
}

// Ensure NULL terminated
*pwzDst = L'\0';

// pwzIDEncoded now contains the entry ID encoded.
return pwzIDEncoded;

}

See Also

About Notification-Based Store Indexing

About MAPI URLs for Notification-Based Indexing