// Get memory allocation function.
LPMALLOC pMalloc = MAPIGetDefaultMalloc();
// Open an IMessage session.
LPMSGSESS pMsgSession = NULL;
hr = OpenIMsgSession(pMalloc, 0, &pMsgSession);
if (FAILED(hr)) throw -1;
// Open an IMessage interface on an IStorage object.
LPMESSAGE pMsg = NULL;
hr = OpenIMsgOnIStg(pMsgSession,
MAPIAllocateBuffer,
MAPIAllocateMore,
MAPIFreeBuffer,
pMalloc,
NULL,
pStorage,
NULL, 0, 0, &pMsg);
if (FAILED(hr)) throw -1;
// Write CLSID to storage.
hr = WriteClassStg(pStorage, CLSID_MailMessage);
if (FAILED(hr)) throw -1;
// Copy message properties from the source msg into msg object in the
storage.
hr = ((LPMESSAGE) pSourceMsg)->CopyTo(0, NULL, NULL, NULL, NULL,
(LPIID) &IID_IMessage, pMsg, 0, NULL);
if (FAILED(hr)) throw -1;
// Save changes in the message object.
hr = pMsg->SaveChanges(KEEP_OPEN_READWRITE);
if (FAILED(hr)) throw -1;
// Save changes in the storage object.
hr = pStorage->Commit(STGC_DEFAULT);
if (FAILED(hr)) throw -1;
It works fine in most cases.
But if message contains huge list of recipients(in my tests more than 533)
it returns an error on the call
"CopyTo" - 0x8007000E - Not enough storage is available to complete this
operation.
However there's enough disk and memory space.
What could it be? Storage size limitation? MAPI bug?
Any ideas are welcome
Thanks in advance.
Thomas Quester
www.outlookfolders.com
"Max Dubinsky" <Ma...@itos.eu.org> wrote in message
news:eBdMpFgiBHA.2372@tkmsftngp04...
Here are my notes on the issue:
This is a problem with root storage and ModifyRecipients. ModifyRecipients
opens a root storage file for each recipient that it adds. This file is
closed, but not released until the transaction is committed. There is a
limit of how many root storages may be opened on a file, bound the amount
of memory available for a process (2/4gig?). See Q163202 for explanation.
Q163202 Limit of the Number of Simultaneously Open Root Storage Files
http://support.microsoft.com/support/kb/Articles/q163/2/02.asp
Stephen Griffin
Microsoft Developer Support - Messaging
This posting is provided “AS IS” with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved
Security Note:
Recent viruses on the Internet underscore the threat to all computer users
and highlight challenges facing the entire industry in providing security
that everyone needs to conduct business. I encourage you to sign up to
receive automatic notification of Microsoft Security Bulletins by visiting
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/
bulletin/notify.asp. For more information on security, our Strategic
Technology Protection Program and to order your FREE Security Tool Kit,
please visit http://www.microsoft.com/security. We will be happy to answer
any questions or provide assistance with your security needs.
"Max Dubinsky" <Ma...@itos.eu.org> wrote in message
news:eBdMpFgiBHA.2372@tkmsftngp04...
As Stephen mentioned it is a limitation of structured storage. Win2000
brings some new API.
Use this code instead to create the storage:
CComPtr<IStorage> spStg;
STGOPTIONS sopts;
sopts.usVersion = 1;
sopts.reserved = 0;
// this one does the trick BUT it blows up your msg files (at least it
works better than 512 = default under NT4)
sopts.ulSectorSize = 4096;
sopts.pwcsTemplateFile = NULL;
// this is a pointer to StgCreateStorageEx which I try to set with
GetProcAdress at program
// start time. It will be NULL if running on pre Win2000.
if(G_pfnStgCreateStorageEx)
{
OutputDebugString("HYPMsgEx::SaveAsMSG is using StgCreateStorageEx
(>=Win2000)\n");
hr = G_pfnStgCreateStorageEx(bstrFileName,
STGM_CREATE | STGM_TRANSACTED | STGM_READWRITE,
STGFMT_DOCFILE, 0, &sopts, 0, IID_IStorage,
(void**)&spStg);
}
else
{
OutputDebugString("HYPMsgEx::SaveAsMSG is using StgCreateDocfile
(<Win2000)\n");
hr = StgCreateDocfile(bstrFileName,
STGM_CREATE | STGM_TRANSACTED | STGM_READWRITE,
0, &spStg);
}
// .. continue with your code
There might be another structured storage limitation in Win2000 but at least
it is much higher than 500 ;-)
In my case it worked fine with about 4000 addresses.
Bye,
Sven
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Sven Carstensen" <Sven.Ca...@gft.com> wrote in message
news:10104332...@tux2.hamburg.gft.com...