Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / November 2006

Tip: Looking for answers? Try searching our database.

Pointer/IntPtr to UCOMIStream?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andreas Baus - 28 Nov 2006 16:56 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.