all groups > dotnet interop > november 2006 >
You're in the

dotnet interop

group:

Pointer/IntPtr to UCOMIStream?


Pointer/IntPtr to UCOMIStream? Andreas Baus
11/28/2006 8:56:38 AM
dotnet interop:
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.
Re: Pointer/IntPtr to UCOMIStream? Mattias Sjögren
11/28/2006 9:46:17 PM
Andreas,

[quoted text, click to view]

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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Re: Pointer/IntPtr to UCOMIStream? Andreas Baus
11/29/2006 1:14:09 AM

Mattias Sj=F6gren schrieb:

[quoted text, click to view]

That's the first thing I tried, but it caused an exception (because of
an arithmetic overflow?!) during the call.
AddThis Social Bookmark Button