I have seen in this newsgroup that numerous others have also been
having problems with the performance of the IMessage::copyTo() method!
At some of my customers sites it is taking 2 minutes! This is not
pleasing the customers... and it is a chain reaction right to my
boss :-)
I too am opening a local .msg file using the code based on that in
MFCMapi. At the end of this posting is a snippet of the code (all
error handling and initialization stuff removed):
It is taking 2 minutes for the copyTo() operation to complete. This
only happens when my MAPI session is online in cached mode. If the
session is offline it is very fast. The copyTo() operation seems to be
triggering the synchronization of the user's OST.
My first attempt was to open it directly without the CopyTo(). This
works except the message is displayed in the form as "not having been
sent". All fields can be editted (To, CC, and the body... etc)
Is the only way to get around this problem to open the message using
ILockBytes (e.g. opening it in memory and not performing a copy of the
message) ?
best regards,
movalgirl
/////////////////////////////////////// code
snippet ///////////////////////////////////////////
LPSTORAGE pStorage = NULL;
LPMALLOC lpMalloc = NULL;
HRESULT hRes = 0;
LPCTSTR szMessageFile = msgFile.c_str();
bool bRet = false;
// get memory allocation function
lpMalloc = MAPIGetDefaultMalloc();
...
hRes = ::StgOpenStorage(
szMessageFile,
NULL,
STGM_READ | STGM_TRANSACTED,
NULL,
0,
&pStorage);
ULONG ulflags = IMSG_NO_ISTG_COMMIT;
// Open an IMessage interface on an IStorage object
hRes = OpenIMsgOnIStg(NULL,
MAPIAllocateBuffer,
MAPIAllocateMore,
MAPIFreeBuffer,
lpMalloc,
NULL,
pStorage,
NULL,
0,
ulflags,
lppMessage);
SizedSPropTagArray (18, excludeTags);
excludeTags.cValues = 18;
excludeTags.aulPropTag[0] = PR_REPLICA_VERSION;
excludeTags.aulPropTag[1] = PR_DISPLAY_BCC;
excludeTags.aulPropTag[2] = PR_DISPLAY_CC;
excludeTags.aulPropTag[3] = PR_DISPLAY_TO;
excludeTags.aulPropTag[4] = PR_ENTRYID;
excludeTags.aulPropTag[5] = PR_MESSAGE_SIZE;
excludeTags.aulPropTag[6] = PR_PARENT_ENTRYID;
excludeTags.aulPropTag[7] = PR_RECORD_KEY;
excludeTags.aulPropTag[8] = PR_STORE_ENTRYID;
excludeTags.aulPropTag[9] = PR_STORE_RECORD_KEY;
excludeTags.aulPropTag[10] = PR_MDB_PROVIDER;
excludeTags.aulPropTag[11] = PR_ACCESS;
excludeTags.aulPropTag[12] = PR_HASATTACH;
excludeTags.aulPropTag[13] = PR_OBJECT_TYPE;
excludeTags.aulPropTag[14] = PR_ACCESS_LEVEL;
excludeTags.aulPropTag[15] = PR_HAS_NAMED_PROPERTIES;
excludeTags.aulPropTag[16] = PR_REPLICA_SERVER;
excludeTags.aulPropTag[17] = PR_HAS_DAMS;
hRes = lpMessage->CopyTo(
0,
NULL,
NULL,
0,
NULL,
&IID_IMessage,
lpNewMessage,
NULL,
NULL
);
hRes = lpNewMessage->SetReadFlag(CLEAR_READ_FLAG);
hRes = lpNewMessage->SaveChanges(KEEP_OPEN_READONLY);
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"movalgirl" <m...@ixos.de> wrote in message
news:2da7b279-3311-4fea...@p35g2000yqh.googlegroups.com...
by "open directly" I mean without using a temporary message created
with the copyTo().
I create an IMESSAGE by using the following sequence of calls...
// I have read the contents of the msg file into memory already
CreateILockBytesOnHGlobal()
StgOpenStorageOnILockBytes()
OpenIMsgOnIStg()
...
(lpTmpMsg)->SetReadFlag(CLEAR_READ_FLAG);
// the following call fails with the error 80070005
(lpTmpMsg)->SaveChanges(KEEP_OPEN_READONLY);
////////////////////////////////////////////////////////////
In other words, when working on an IMESSAGE directly without the copyTo
() to a temporary message
I cannot issue the SaveChanges() command.
This is all a workaround because of my original problem. The extemely
slow IMessage::CopyTo() operation when the MAPI session
is cached online.
Regards,
Michelle
On 11 Nov., 17:33, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> What do you mean by "open it directly ?
> To maake sure message gets displayed in the sent mode, you just need to
> remove MSGFLAG_UNSENT bit from the PR_MESSAGE_FLAGS proeprty.
>
> --
> Dmitry Streblechenko (MVP)http://www.dimastr.com/
> > hRes = lpNewMessage->SaveChanges(KEEP_OPEN_READONLY);- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"movalgirl" <m...@ixos.de> wrote in message
news:0dd46618-9e53-45f4...@a32g2000yqm.googlegroups.com...
On 17 Nov., 18:35, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> The error is MAPI_E_NO_ACCESS.
> Have you tried to use KEEP_OPEN_READWRITE flag?
>
> --
> > - Zitierten Text anzeigen -- Zitierten Text ausblenden -