Can anyone help with the following...
I have some vbscript in a custom outlook form that accesses the entryid
and storeid of the current item...
strEntryId = item.entryid
strStoreId = item.parent.storeid
it then calls a C++ COM object and passes the ids as parameters
set omyObj = createObject("testy.MyObject")
call omyObj.ViewItem(strEntryid, strStoreid)
My COM object picks these parameters up as BSTRs.
From my COM object I want to access some custom properties on the item so
I create a piggyback MAPI session and try and open the message store with
OpenMsgStore(). Before I do this I have to convert the BSTR into a
LPENTRYID and this I do using HrEntryIDFromSz after having first
converted my BSTR to an ASCII string array.
My problem is that the HrEntryIDFromSz call fails with a status
MAPI_E_INVALID_ENTRYID.
I know I can achieve what I need using CDO instead of Extended MAPI, but
I do not want to rely on CDO and want a solution that does not us it.
Any ideas greatly appreciated.
Mike
Here is a snippet from my COM code...
STDMETHODIMP CtestyMyObject::ViewItem(BSTR entryId, BSTR storeId)
{
HRESULT hr = E_FAIL;
CComPtr<IMAPISession> pMAPISession;
CComPtr<IMsgStore> pMsgStore;
LPENTRYID pStoreId;
ULONG cbLen;
hr = MAPILogonEx(0, NULL, NULL,
MAPI_ALLOW_OTHERS|MAPI_EXTENDED, &pMAPISession);
// Open the message store
//
if (hr == S_OK)
{
LPTSTR Str;
// convert BSTR to ASCII string
unsigned Len = wcstombs(NULL, entryId,
SysStringLen(entryId)) + 1;
Str = new TCHAR[Len];
wcstombs(Str, entryId, Len-1);
Str[Len -1] = 0;
hr = HrEntryIDFromSz(Str, &cbLen, &pStoreId);
}
if (hr == S_OK)
{
hr = pMAPISession->OpenMsgStore(NULL,
cbLen, pStoreId,
NULL,
MDB_NO_MAIL|MDB_NO_DIALOG|MDB_TEMPORARY,
&pMsgStore);
}
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Mike Jipson" <mji...@nospam.hotmail.com> wrote in message
news:MPG.14eb70f87...@nntp.netcom.net.uk...