Groups | Blog | Home
all groups > dotnet interop > june 2004 >

dotnet interop : MAPI and P/Invoke


David B. Bitton
6/11/2004 7:48:59 PM
I am coding an Outlook 2003 plugin in C#. It has become apparent that the
only way to get at the data that comprises an email attachment without
saving it to disk first is to use the MAPI. The call to MAPIInitialize is
no problem and returns with an S_OK. What I'm not quite sure how to do is
define in C# the IAttach interface (which derives from IMAPIProp and does
not define any methods of its own).

The way I understand it, I should be able to cast the Attachment.MAPIOBJECT
property to IAttach and then call OpenProperty() on the interface. As you
are aware, MAPI is not a COM object, so Marshal.QueryInterface() won't
(shouldn't) work. The other thing is the definition if IMAPIProp in
MAPIDefs.h is confusing, and since I'm not an experienced C programmer, I'm
not 100% sure what I'm looking at.

I have looked into using Redemption, but it seems silly to use a COM object
from C# when I could just implement the same code in a managed environment.
www.mapilab.com has some free code for doing just OpenProperty calls, but
it's written as a COM wrapper. I've looked at the C++ code and it doesn't
seem very complicated; I just don't know how to adapt it to a Managed C++
wrapper from a COM wrapper.

Anyone with some ideas, or know where they can direct me, I would greatly
appreciate it. Thanks.

--
--

David B. Bitton
david@codenoevil.com
www.codenoevil.com

Code Made Fresh DailyT

mapi33dev NO[at]SPAM yahoo.com
6/15/2004 1:54:23 AM
Hi David

Try to use mapi33 library.
AddThis Social Bookmark Button