This is a copy from phone_edition group, and any better
suggestions???????
In my work, I need store some flags whick indicate some states of
every
message in tmail.exe. This flags should be persistent, namely these
data
shouldn't losed and can be take out after a while even if the
tmail.exe
process is killed.
I have tried the IMAPIProp::GetIDsFromName(..) API as following code,
but it
can't work because the PROPERTY TYPE returned by GetProps(...) is
PT_ERROR
Is there some error within the code segment? or can I use other ways
to
store those flags, for example the untapped properties or untapped
bits in
message state property ?
Many thanks for your advice.
//code begin
GUID gu = { 0x00020328, 0, 0, { 0xC0, 0, 0, 0, 0, 0, 0, 0x46 } };
MAPINAMEID hms; // a custom name in it
MAPINAMEID * pMAPINameID = &hms;
memset(&hms, 0, sizeof(MAPINAMEID));
hms.lpguid = &gu;
hms.ulKind = MNID_STRING;
hms.Kind.lpwstrName = L"CustName";
LPSPropTagArray rgStatueTag = NULL;
hr = m_pMsgItem->GetIDsFromNames(1, &pMAPINameID, MAPI_CREATE,
&rgStatueTag);
if (hr == MAPI_E_NO_SUPPORT)
MessageBox(NULL, L"MAPI_E_NO_SUPPORT", L"ERROR", MB_OK);
else if (hr == E_UNEXPECTED)
MessageBox(NULL, L"E_UNEXPECTED", L"ERROR", MB_OK);
else if (hr == MAPI_E_UNKNOWN_FLAGS)
MessageBox(NULL, L"MAPI_E_UNKNOWN_FLAGS", L"ERROR", MB_OK);
else if (hr == MAPI_W_ERRORS_RETURNED )
MessageBox(NULL, L"MAPI_W_ERRORS_RETURNED ", L"ERROR", MB_OK);
else if (hr == MAPI_E_TOO_BIG)
MessageBox(NULL, L"MAPI_E_TOO_BIG", L"ERROR", MB_OK);
else if (hr == E_INVALIDARG)
MessageBox(NULL, L"E_INVALIDARG", L"ERROR", MB_OK);
//get the prop type in rgStatueTag[0]
WORD wPropType = LOWORD(rgStatueTag->aulPropTag[0]);
//yihect 8.9 ; yes , the type of property is not specified.
//so need use GetProps() to get accurate property type.
if (wPropType == PT_UNSPECIFIED)
MessageBox(NULL, L"UNSPECIFIED PROP TYPE", L"warn", MB_OK);
//yihect 8.9 GetProps return S_OK in hr.
hr = m_pMsgItem->GetProps(rgStatueTag, MAPI_UNICODE, &uValues,
&rgStatueProp);
CHR(hr);
//determine the property type in rgStatueProp
//yihect 8.9 return type of PT_ERROR(10), not PT_SHORT
wPropType = LOWORD(rgStatueProp[0].ulPropTag);
if (wPropType == PT_SHORT)
MessageBox(NULL, L"PT_SHORT PROP TYPE", L"warn", MB_OK);;
//code end