Re: WrapCompressedRTFStream() produces bad data
- From: "asnowfall@xxxxxxxxx" <asnowfall@xxxxxxxxx>
- Date: 13 Feb 2007 23:17:00 -0800
Thanks for your swift response. Here is the code
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This is code is reading-in the PR_RTF_COMPRESSED from TNEF file.
IStream* pStream;
hr = CreateStreamOnHGlobal(0, TRUE, &pStream);
pStream->Write( &m_byteTnefData[ m_iBufferIndex], dwSizeOfReadyData,
&dwBytesCopied);
pStream->Seek(zero, STREAM_SEEK_SET, 0); //Reset the stream index to 0
//Uncompressing PR_RTF_COMPRESSED stream
HRESULT hr = 0;
ULONG num_written = 0UL;
BYTE buffer[4096];
ULONG num_read = 0UL;
LARGE_INTEGER x1 = { 0 };
MAPIINIT_0 pMapiInit = { MAPI_INIT_VERSION, 0x00000008 };
MAPIInitialize(&pMapiInit);
if((objMessageProps.m_dwMapiStorageSupportMask &
STORE_UNCOMPRESSED_RTF) != STORE_UNCOMPRESSED_RTF)
{
IStreamPtr spUncompressed;
hr = WrapCompressedRTFStream( objMessageProps.m_objRtf,
STORE_UNCOMPRESSED_RTF , &spUncompressed);
if( hr == 0)
{
hr = CreateStreamOnHGlobal(0, TRUE,
&objMessageProps.m_objRtfUncomp);
}
if( hr == 0)
{
while( (spUncompressed->Read(buffer, sizeof(buffer),
&num_read) == S_OK) && (hr == 0))
{
if(num_read == 0)
break;
hr = objMessageProps.m_objRtfUncomp->Write(buffer,
num_read, &num_written);
}
objMessageProps.m_objRtfUncomp->Seek(x1, STREAM_SEEK_SET,
0);
}
}
//////////////////////////////////////////////////////////////////////////////////
I tried using MAPIINIT_0 pMapiInit = { MAPI_INIT_VERSION, 0 }; and
that did not make any difference.
Once for testing, to WrapCompressedRTFStream(), I fed an IStream
object without having set it's index to 0 and API returned me a got an
error.
I did this test to make sure WrapCompressedRTFStream() is responding.
As you see I am using CreateStreamOnHGlobal() at both places.
Thanks
Ramesh
On Feb 14, 12:50 am, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx>
wrote:
Please post your code.
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
<asnowf...@xxxxxxxxx> wrote in message
news:1171427205.690394.37380@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I wish someone can help me!!!!
WrapCompressedRTFStream() is returning S_OK but it is returning
corrupt data. Buffer returned by this API does have any RTF headers
and looks like a BINARY blob.
I am extracting PR_RTF_COMPRESSED stream from a TNEF file by parsing
the winmail.dat. This means I do not have any MAPI code except for
MAPIInitialize(). I thought my PR_RTF_COMPRESSED is corrupt, so I
opened winmail.dat using MfcMapi.exe; and i saw that PR_RTF_COMPRESSED
shown there is exactly with the stream what I am feeding to
WrapCompressedRTFStream(). I opened the winmail.dat in binary editor
and I was able to LZFU, compressed-rtf signature.
Even Winmail.exe, a TNEF viewer, is able to display the message body
contained in the winmail.dat.
So the stream is correct but I must be doing something wrong, please
help me.
I think following might be causing some problem
1) I might not have initiliazed MAPI properly. Currently I have just
called MAPIInitialize().
2) The IStream that is being passed to WrapCompressedRTFStream() is
created using CreateStreamOnHGlobal();
and the stream returned by this API might have some limitations.
Please help me figure this out...
TIA
Ramesh- Hide quoted text -
- Show quoted text -
.
- References:
- WrapCompressedRTFStream() produces bad data
- From: asnowfall@xxxxxxxxx
- Re: WrapCompressedRTFStream() produces bad data
- From: Dmitry Streblechenko
- WrapCompressedRTFStream() produces bad data
- Prev by Date: Re: WrapCompressedRTFStream() produces bad data
- Next by Date: WebDAV SEARCH: (422) Unprocessable Entity
- Previous by thread: Re: WrapCompressedRTFStream() produces bad data
- Next by thread: Re: WrapCompressedRTFStream() produces bad data
- Index(es):
Relevant Pages
|