C++/VB - 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
Outlook
(1)
LPSBinary
(1)
GetAttachmentTable
(1)
CComPtr
(1)
OpenProperty
(1)
OutlookSpy
(1)
OpenAttach
(1)
UlObjType
(1)
  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
-
help
0x80029C4A Error loading type library / DLL. Related to Outlook.Application. C++ / VB I have a customer getting the above error in a program that uses the "Outlook.Application" object. I have verified the registry looks ok (see the information below). How can more information about the problem so that it can be solved? Thanks, Frank - -- -- -- -- -- -- -- -- -- -- -- - Subject: Re: Outlook.Application HKEY_CLASSES_ROOT \ Outlook.Application = Microsoft Outlook 10.0 Object Library HKEY_CLASSES_ROOT \ Outlook.Application \ CLSID = {0006F03A-0000-0000-C000-000000000046} HKEY_CLASSES_ROOT \ Outlook.Application = Outlook.Application.10 HKEY_CLASSES_ROOT \ Outlook.Application.10 = Microsoft Outlook 10.0 Object Library HKEY_CLASSES_ROOT \ Outlook.Application
Outlook Automation Problem utilizing Microsoft.Office.Interop.Outl C++ / VB Development Tool VB.Net 2005, Outlook Object 11.0. Reading Emails into a DataGridView. Utilizing the Interop. Receiving the following message (not from vb.net), from Outlook. outlook \ . . ." could not be installed or loaded. This message comes up usually after about 200 emails appear, problem is too slow. Some of the code: Dim oAppm As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application Dim oInboxm As Microsoft.Office.Interop.Outlook.MAPIFolder Dim oItemsm As Microsoft.Office.Interop.Outlook.Items Dim oNSm As Microsoft.Office.Interop.Outlook.NameSpace = oAppm.GetNamespace("MAPI") oInboxm = oNSm.GetDefaultFolder
Dim objShell objShell.Run("del / F / Q ""C: \ Documents and Settings \ amaltais \ Application Data \ Microsoft \ Outlook \ Outlook.NK2""") VB Syntax Discussions Outlook (1) Specifies (1) ObjShell (1) Medicalintelligence (1) Acuralex54 (1) Attributes (1) Directory (1) Plz (1 Dim objShell objShell.Run(del / F / Q C: \ Documents and Settings \ amaltais \ Application Data \ Microsoft \ Outlook \ Outlook.NK2)
Extracting Embedded images in Outlook 2007 C++ / VB In Outlook 2003 I had a macro to extract embedded images. This is it Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell Nothing End Sub I do not know VB. However when I put this macro in Outlook 2007 I get this error message Can someone help me? Regards Doug VB COM Discussions Application.ActiveInspector.CurrentItem (1) Outlook 2007 (1) Outlook 2003 (1) Outlook.MailItem (1) WScript.Shell (1) VBA (1) VB (1) ObjAttachment.SaveAsFile (1