I'm currently trying to retrieve the RFT body of messages in Outlook
(from an app written in C#), and since that is, from what I gather, not
supported by the Outlook object model, I had to dig deeper into MAPI.
Now, I think I am on to something, but I am kind of stuck at one point:
It seems I can use the Function HrGetOneProp(...) to retrieve the value
of the PR_RTF_COMPRESSED property, which according to the documentation
is a pointer to an IStream object containing the compressed RTF. Now I
somehow need to pass this stream through the
WrapCompressedRTFStream(...) function to get a stream of UNcompressed
RTF, and according to what I found so far, I have to wrap the streams
into UCOMIStream, but I don't know how to create one of those from the
pointer I got from the call to HrGetOneProp.
Here's the relevant bit of my code:
// Suppose we have a pointer to the IMAPIProp interface of the
// MailItem object whose RTF body we want
IntPtr pPropValue;
HrGetOneProp(pIMAPIProp, PR_RTF_COMPRESSED, out pPropValue);
PropValueStruct propValue = (PropValueStruct)Marshal.PtrToStructure(
pPropValue, typeof(PropValueStruct));
IntPtr pIStream = new IntPtr(propValue.value);
UCOMIStream compressedStream = /* here, some magic happens */
UCOMIStream uncompressedStream;
WrapCompressedRTFStream(compressedStream, 0,
out uncompressedStream);
// Dump the contents of uncompressedStream somewhere usable,
// and we're done.
The magic part in the middle eludes me. If anyone has any idea, I'd
love to hear it.
Mattias Sjögren - 28 Nov 2006 20:46 GMT
Andreas,
>Now I somehow need to pass this stream through the
>WrapCompressedRTFStream(...) function to get a stream of UNcompressed
>RTF, and according to what I found so far, I have to wrap the streams
>into UCOMIStream, but I don't know how to create one of those from the
>pointer I got from the call to HrGetOneProp.
Seems it would be easier to change the declaration of
WrapCompressedRTFStream so it takes an IntPtr as the first parameter.
Also remember to Marshal.Release the stream when you're done with it.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Andreas Baus - 29 Nov 2006 09:14 GMT
Mattias Sjögren schrieb:
> Seems it would be easier to change the declaration of
> WrapCompressedRTFStream so it takes an IntPtr as the first parameter.
That's the first thing I tried, but it caused an exception (because of
an arithmetic overflow?!) during the call.