Outlook
(1)
LPSBinary
(1)
GetAttachmentTable
(1)
CComPtr
(1)
OpenProperty
(1)
OutlookSpy
(1)
OpenAttach
(1)
UlObjType
(1)

Fails to open Embedded Message with error 0x80004005

Asked By Sameer
19-Nov-09 10:05 AM
Hi There,

We have Email Archive application which will continuesly fetch the
email from Journaling mailbox. Envelope Journaling is turned on and
thus all the messages are embedded attached messages.

The application is working for some time and we are able to process
the embedded messages. At one point/time MAPI call
IMessage::OpenProperty() fails with the error 0x80004005
(MAPI_E_CALL_FAILED) and failed to open/process the embedded message.
Once we recieve this error, all subsequent messages fetch from
journaling mailbox also reports the same error. We move/store these
failed archived messages to "Sent Items" folder.

If we restart our applications and move the above failed messages from
without any error. The application will work over the period and again
start recieving error 0x80004005 (MAPI_E_CALL_FAILED).

Your help and time is appreciated in advance.

Following is the C++ code snapshot we are using...


CComPtr<IAttach> pAttach;

//Step 1 - Open the envelope based on the LTID
if (FAILED (hr = m_pSession->OpenEntry( lpEid->cb,	//LPSBinary lpEid
is passed
(LPENTRYID)lpEid->lpb,
NULL,
MAPI_MODIFY ,
&ulObjType,
(IUnknown **)&pEnvelope.p) ))
{
return hr ;
}


//Setp 2 - Once we have the envelope we get the 1st attachment, which
is the message.
//		   Remember the message is always in position 0 of the envelope.

ULONG ulFlags = MAPI_DEFERRED_ERRORS ;
if ( FAILED (hr = pEnvelope->OpenAttach( 0,
NULL,
ulFlags,
&pAttach.p ) ))
{
return hr ;
}


//Step 3 - Now that we have the attachment we need to query for the
the message.

if ( FAILED(hr = pAttach->OpenProperty( PR_ATTACH_DATA_OBJ ,
(LPIID)&IID_IMessage,
0,
MAPI_MODIFY ,
(IUnknown **)&pMsg.p) ))
{
return hr ;
}

Thanks,
Sameer

When you call pEnvelope->OpenAttach(), you assume that the value

Dmitry Streblechenko replied to Sameer
19-Nov-09 11:30 AM
When you call pEnvelope->OpenAttach(), you assume that the value of
PR_ATTACH_NUM is always 0,
Most likely than not, this is not the case.
The value of PR_ATTACH_NUM must be retrieved from the attachment table
(IMessage::GetAttachmentTable).

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