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 (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...
Though this block is actually enforced on open, not creation.
Steve
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:%231o5wuf...@TK2MSFTNGP04.phx.gbl...
> 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:
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
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message
news:%231o5wuf...@TK2MSFTNGP04.phx.gbl...