access rights to MAPI objects

Y

Yaroslav

Can I somehow change the access right to IMessage mapi object?

When the message appears in the outbox I do the following

LPMESSAGE lpMessage = NULL;
HRESULT hRes = spMDB->OpenEntry( MessageId->Value.bin.cb,(LPENTRYID) MessageId->Value.bin.lpb, NULL, MAPI_BEST_ACCESS, &ulObjType,(LPUNKNOWN *)&lpMessage);

if (SUCCEEDED(hRes) && ulObjType == MAPI_MESSAGE)
{

SizedSPropTagArray(1,sptCols) = {1, PR_MY_PROP};
hRes = lpMessage->DeleteProps((LPSPropTagArray)&sptCols, 0);
hRes = lpMessage->SaveChanges(KEEP_OPEN_READWRITE);

... do some action on message and send it ....
}
But the lpMessage->DeleteProps returns error code that is access denied.
spMDB is the ATL::CComPtr<IMsgStore>
PR_MY_PROP is the property which I add in the BeforeMessageSend method handler (this I use to mark the message so that to handle this message only once since I receive several notification in the OnNotify method). I tried even with MAPI_BEST_ACCESS|MAPI_MODIFY but it also appears with no success.
Any ideas on this?
 
D

Dmitry Streblechenko

Did you open the parent store (spMDB) in the write mode?
What are the values of the PR_ACCESS and PR_ACCESS_LEVEL properties?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Y

Yaroslav

spMDB is actually the default message store and it is opened with the MAPI_BEST_ACCESS. I open it using lpMAPISession->OpenMsgStore() (iterate over all rows of msg store table and look for one having ulPropTag == PR_DEFAULT_STORE and than open it).

PR_ACCESS_LEVEL for IMessage
LPSPropValue accessProp;
hRes = HrGetOneProp(lpMessage, PR_ACCESS_LEVEL, &accessProp));
accessProp->Value.l is equal to 0 (don't know what this value mean)

PR_ACCESS_LEVEL for IMsgStore
hRes = HrGetOneProp(spMDB, PR_ACCESS_LEVEL, &accessProp));
accessProp->Value.l is equal to 1 (this is MAPI_ACCESS_MODIFY ((ULONG) 0x00000001))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top