This article explains how to convert the PR_ENTRYID value of an item or folder in MFCMAPI to a REST ID that Microsoft Graph can use.
For example, consider this PR_ENTRYID value:
1 | 000000008D6CA63CDFB18D44933B27DCE7E85C5207001E0CC5CE7C4D0446BE4F970F82B9B02600000000010C00001E0CC5CE7C4D0446BE4F970F82B9B0260002FC5A18060000 |
This value represents binary data in hexadecimal. Microsoft Graph’s translateExchangeIds can convert a PR_ENTRYID, but you cannot use the value as it is. First, do the following:
- Convert it to a byte array.
- Encode it as Base64.
- Convert it to a URL-safe format.
In PowerShell, you can perform the first two steps as follows. The Base64-encoded result is stored in $Base64EntryID.
1 | $PR_ENTRYID = "000000008D6CA63CDFB18D44933B27DCE7E85C5207001E0CC5CE7C4D0446BE4F970F82B9B02600000000010C00001E0CC5CE7C4D0446BE4F970F82B9B0260002FC5A18060000" |
Next, replace + with - and / with _. Remove the trailing padding characters (=), and append the number of removed characters (0, 1, or 2).
1 | $Base64EntryID = $Base64EntryID.Replace('+', '-').Replace('/', '_') |
$Base64EntryID now contains the URL-safe value. It should look like this:
1 | AAAAAI1spjzfsY1Ekzsn3OfoXFIHAB4Mxc58TQRGvk-XD4K5sCYAAAAAAQwAAB4Mxc58TQRGvk-XD4K5sCYAAvxaGAYAAA2 |
The value is now ready to use with translateExchangeIds. Send a request like this to convert it to a REST ID:
1 | POST https://graph.microsoft.com/v1.0/me/translateExchangeIds |
A response like the following indicates success. The targetId is in REST ID format and can be used as an ID in Microsoft Graph.
1 | HTTP/1.1 200 OK |