Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Msg files with large number of receipients

32 views
Skip to first unread message

Devesh Sarwate

unread,
Sep 26, 2008, 8:34:04 PM9/26/08
to
Hi All,
Are there any known issues in creating Msg files by exporting messages that
have large number of recpients or attachments. I have written some code to
export a message to MSg file and it works fine but I recently heard from a
friend who had done this earlier that creation of MSg files fail with out of
memory errors when the number of recpients in the message is high (> 512). I
tried my code with a message with more than 512 recipients and it worked
fine so I am not sure if there is any issue at all.

Also Is there a limit on size of message that can be exported to a MSG file
? Although i do not see any errors right now, I would want to cover known
issues in the code.

here is the my code snippet:

//m_spMessage is a CComPtr<IMessage> member of the class, this is the
message being exported to the MSg file


HRESULT MsiMAPIMessage::SaveAsMsgFile( const std::wstring & strMsgFilePath)
{
HRESULT hr = S_OK;
LPMSGSESS pMsgSession = NULL;

try
{

CComPtr<IStorage> spStorage;

hr = StgCreateStorageEx
(
strMsgFilePath.c_str(),
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
STGFMT_STORAGE,
0,
NULL,
0,
IID_IStorage,
(void **)&spStorage
);
COM_ERROR_CHECK(hr, L"StgCreateStorageEx");

SizedSPropTagArray ( 8, arrayExcludeTags) =
{
8,
{
PR_BODY,
PR_RTF_SYNC_BODY_COUNT,
PR_RTF_SYNC_BODY_CRC,
PR_RTF_SYNC_BODY_TAG,
PR_RTF_SYNC_PREFIX_COUNT,
PR_RTF_SYNC_TRAILING_COUNT,
PR_RECEIVED_BY_ENTRYID,
PR_RECEIVED_BY_SEARCH_KEY,
}
};


CComPtr<IMalloc> spMalloc;
CComPtr<IMessage> spMessage;

spMalloc = MAPIGetDefaultMalloc();
hr = OpenIMsgSession(spMalloc, 0, &pMsgSession);
COM_ERROR_CHECK(hr, L"OpenIMsgSession");

// Open an IMessage interface on an IStorage object
hr = OpenIMsgOnIStg
(
pMsgSession,
MAPIAllocateBuffer,
MAPIAllocateMore,
MAPIFreeBuffer,
spMalloc,
NULL,
spStorage,
NULL,
0,
0,
&spMessage
);
COM_ERROR_CHECK(hr, L"OpenIMsgOnIStg");

hr = WriteClassStg(spStorage, CLSID_MailMessage);
COM_ERROR_CHECK(hr, L"WriteClassStg CLSID_MailMessage");

hr = m_spMessage->CopyTo(0,NULL,(LPSPropTagArray)&arrayExcludeTags, NULL,
NULL,(LPCIID)&IID_IMessage,spMessage, 0, NULL);
MAPI_ERROR_CHECK(hr, L"m_spMessage->CopyTo spMessage", m_spMessage);

hr = spMessage->SaveChanges(KEEP_OPEN_READWRITE);
MAPI_ERROR_CHECK(hr, L"spMessage->SaveChanges", spMessage);

hr = spStorage->Commit(STGC_DEFAULT);
COM_ERROR_CHECK(hr, L"spStorage->Commit");

}
catch(std::exception & ex)
{
hr = GetExceptionHRESULT(ex);
//log here
}

if (pMsgSession)
{
CloseIMsgSession(pMsgSession);
pMsgSession = NULL;
}

return hr;
}


Thanks
Devesh


Dmitry Streblechenko

unread,
Sep 29, 2008, 2:21:58 AM9/29/08
to
When you call StgCreateStorageEx, instead of NULL, pass a pointer to an
StgOptions struct and specify StgOptions.ulSectorSize=4096.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Devesh Sarwate" <Devesh....@gmail.com> wrote in message
news:%233KAAjD...@TK2MSFTNGP05.phx.gbl...

Stephen Griffin

unread,
Sep 29, 2008, 9:18:05 AM9/29/08
to
There's actually now a configurable block of 2048 recipients or attachments:
Outlook 2003: http://support.microsoft.com/kb/948074
Outlook 2007: http://support.microsoft.com/kb/952295

Though this block is actually enforced on open, not creation.

Steve

"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:%231o5wuf...@TK2MSFTNGP04.phx.gbl...

SvenC

unread,
Sep 29, 2008, 2:48:07 PM9/29/08
to
Hi Stephen,

> There's actually now a configurable block of 2048 recipients or
> attachments: Outlook 2003: http://support.microsoft.com/kb/948074
> Outlook 2007: http://support.microsoft.com/kb/952295

There is a typo in the OL2003 version:

SvenC

unread,
Sep 29, 2008, 3:22:13 PM9/29/08
to
Hi Stephen Griffin wrote:
> There's actually now a configurable block of 2048 recipients or
> attachments: Outlook 2003: http://support.microsoft.com/kb/948074
> Outlook 2007: http://support.microsoft.com/kb/952295

sorry, clicked return too fast.

The error in the OL2003 article is in this sentence:

Note The default value for the AttachmentMax setting and for the
RecipientMax setting is 2048 *bytes*

--
SvenC

Devesh Sarwate

unread,
Sep 30, 2008, 8:55:23 PM9/30/08
to
Thanks Dimtry and Steve. The combination of your solutions solves the
problems that I found during my testing with larger number of
receipients/Attachments

"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:%231o5wuf...@TK2MSFTNGP04.phx.gbl...

0 new messages