M
Mark Cote
Following some recommendations found in this group, I have recently
implemented a system to index appointments based on global IDs instead
of entry IDs. I am now attempting to write some code to set the
global ID property if it is not found (such as in Outlook 2002), but I
cannot get it to work. I am fairly new to MAPI programming and have
not been able to find examples or articles to help me specifically
with this problem; in particular, there is little discussion of how to
set (a) binary properties and (b) non-existent properties, both of
which are involved in setting a global ID, from what I understand.
This is my code thus far (error handling removed for readability). I
don't know if the problem is in how I'm setting up the LPSPropValue or
if it's something else altogether.
// lpMsg (used below) is an IMessage obtained
// from Outlook::_AppointmentItem::get_MAPIOBJECT().
LPSPropTagArray lpNamedPropTag = NULL;
// This function sets lpNamedPropTag to the tag of the global object
ID.
// This is verified to work for getting global object IDs in Outlook
2003 and 2007.
GetGlobalObjectIdPropTag(lpMsg, lpNamedPropTag);
// Set a global ID based on our entry ID.
// Get Entry ID.
ULONG ulVal = 0;
LPSPropValue lpPropVal = NULL;
SPropTagArray lpPropTagArray;
lpPropTagArray.cValues = 1;
lpPropTagArray.aulPropTag[0] = PR_ENTRYID;
lpMsg->GetProps(&lpPropTagArray, 0, &ulVal, &lpPropVal);
// Prefix for global ID.
BYTE globalID[44] = {0x04, 0x00, 0x00, 0x00, 0x82, 0x00, 0xE0, 0x00,
0x74, 0xC5,
0xB7, 0x10, 0x1A, 0x82, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00};
// Use entry ID as unique identifier after prefix.
memcpy(&globalID[20], lpPropVal->Value.bin.lpb, 24);
MAPIFreeBuffer(lpPropVal);
MAPIAllocateBuffer(sizeof(SPropValue), (LPVOID *)&lpPropVal);
MAPIAllocateMore(44, (LPVOID)lpPropVal, (LPVOID *)&lpPropVal-
lpPropVal->ulPropTag = lpNamedPropTag->aulPropTag[0];
memcpy(lpPropVal->Value.bin.lpb, globalID, 44);
LPSPropProblemArray lppProblems;
lpMsg->SetProps(1, lpPropVal, &lppProblems);
// Cleanup
MAPIFreeBuffer(lpPropVal);
MAPIFreeBuffer(lpNamedPropTag);
Thanks,
Mark
implemented a system to index appointments based on global IDs instead
of entry IDs. I am now attempting to write some code to set the
global ID property if it is not found (such as in Outlook 2002), but I
cannot get it to work. I am fairly new to MAPI programming and have
not been able to find examples or articles to help me specifically
with this problem; in particular, there is little discussion of how to
set (a) binary properties and (b) non-existent properties, both of
which are involved in setting a global ID, from what I understand.
This is my code thus far (error handling removed for readability). I
don't know if the problem is in how I'm setting up the LPSPropValue or
if it's something else altogether.
// lpMsg (used below) is an IMessage obtained
// from Outlook::_AppointmentItem::get_MAPIOBJECT().
LPSPropTagArray lpNamedPropTag = NULL;
// This function sets lpNamedPropTag to the tag of the global object
ID.
// This is verified to work for getting global object IDs in Outlook
2003 and 2007.
GetGlobalObjectIdPropTag(lpMsg, lpNamedPropTag);
// Set a global ID based on our entry ID.
// Get Entry ID.
ULONG ulVal = 0;
LPSPropValue lpPropVal = NULL;
SPropTagArray lpPropTagArray;
lpPropTagArray.cValues = 1;
lpPropTagArray.aulPropTag[0] = PR_ENTRYID;
lpMsg->GetProps(&lpPropTagArray, 0, &ulVal, &lpPropVal);
// Prefix for global ID.
BYTE globalID[44] = {0x04, 0x00, 0x00, 0x00, 0x82, 0x00, 0xE0, 0x00,
0x74, 0xC5,
0xB7, 0x10, 0x1A, 0x82, 0xE0, 0x08, 0x00, 0x00, 0x00, 0x00};
// Use entry ID as unique identifier after prefix.
memcpy(&globalID[20], lpPropVal->Value.bin.lpb, 24);
MAPIFreeBuffer(lpPropVal);
MAPIAllocateBuffer(sizeof(SPropValue), (LPVOID *)&lpPropVal);
MAPIAllocateMore(44, (LPVOID)lpPropVal, (LPVOID *)&lpPropVal-
lpPropVal->Value.bin.cb = 44; // 20-byte prefix plus 24-byte entry IDValue.bin.lpb);
lpPropVal->ulPropTag = lpNamedPropTag->aulPropTag[0];
memcpy(lpPropVal->Value.bin.lpb, globalID, 44);
LPSPropProblemArray lppProblems;
lpMsg->SetProps(1, lpPropVal, &lppProblems);
// Cleanup
MAPIFreeBuffer(lpPropVal);
MAPIFreeBuffer(lpNamedPropTag);
Thanks,
Mark