Bruce
Guest
|
Posted:
Fri Sep 09, 2005 12:59 am Post subject:
Problems with HrSzFromEntryID() and HrEntryIDFromSz() using |
|
|
I am trying to figure out what is wrong with this code sample. I want to be
able to convert an ENTRY_ID for a mail message from ENTRYID to STRING and
back. From what I can tell in the documentation, this should work. I have
outlook 2003 with all the updates installed.
mapi32.dll Info:
Extended MAPI 1.0 for Windows NT
File Version: 1.0.2536.0
Running on Windows XP Pro.
bin.cb = 0x00000018
bin.lpb points to short term ENTRYID data from a message.
All I am doing is converting an message's entryid it to a string and back
again.
The string the entryid is converted to is:
"08[P```"V"_D;[<+!'C7[7,^P,L5D$4S<`"
When I try to convert it back I get the following results:
HRESULT: 0x80040107
lcbTemp = 0x0000004e
lpTempEntryID= 0
HERE IS THE CODE SAMPLE
// Convert ENTRYID to STRING
LPTSTR lpszEntryID = NULL;
HrSzFromEntryID(
pRows->aRow[i].lpProps[ePR_ENTRYID].Value.bin.cb
, (LPENTRYID)pRows->aRow[i].lpProps[ePR_ENTRYID].Value.bin.lpb
, &lpszEntryID
);
TRACE("EntryID: %s\n",lpszEntryID);
// Convert STRING to ENTRYID
ULONG lcbTemp = 0;
LPENTRYID lpTempEntryID = NULL;
HRESULT hrReturnTemp = HrEntryIDFromSz(lpszEntryID, &lcbTemp,
&lpTempEntryID);
if (lpTempEntryID)
{
MAPIFreeBuffer(lpTempEntryID);
lpTempEntryID = NULL;
}
if (lpszEntryID)
{
MAPIFreeBuffer(lpszEntryID);
lpszEntryID = NULL;
}
--
Thanks,
Bruce
|
|
Dan Mitchell
Guest
|
Posted:
Sat Sep 10, 2005 12:58 am Post subject:
Re: Problems with HrSzFromEntryID() and HrEntryIDFromSz() us |
|
|
"Bruce" <bwolven@nospam.nospam> wrote in
news:e5ITVwLtFHA.1472@TK2MSFTNGP15.phx.gbl:
| Quote: | ULONG lcbTemp = 0;
LPENTRYID lpTempEntryID = NULL;
HRESULT hrReturnTemp = HrEntryIDFromSz(lpszEntryID, &lcbTemp,
&lpTempEntryID);
|
The problem is that these functions are designed for going between
Simple MAPI and Extended MAPI; from the docs for HrSzFromEntryID:
"When the client finds the entry identifier for the desired message, it
can call HrSzFromEntryID to convert the entry identifier to a Simple
MAPI identifier string so the message can be manipulated in Simple MAPI.
"
So far, so good.
"Then the client can call the Simple MAPI MAPIReadMail function to
retrieve the required information about the message. "
In other words, that ENTRYID is meant to be passed to MAPIReadMail, not
HrEntryIDFromSz. You'd think those functions would be symmetrical with
ExMAPI ENTRYIDs, but I guess not. It looks very much as if the to-string
function is turning it into a human-readable string, too, which is a bit
suspicious.
You probably want the HexFromBin and FBinFromHex functions.
-- dan |
|