Currently developing an Outlook add-in with Add-in Express, I have to revert to some pure MAPI functions for reading MAPI properties.
Having this P/Invoke wrapper to the HrGetOneProp
function:
[DllImport(@"MAPI32.DLL")]
static extern int HrGetOneProp(IntPtr pmp, uint ulPropTag, out IntPtr ppProp);
I'm trying to pass an Outlook attachment object of type IMAPIProp
as the first parameter to the function.
what I'm currently failing in is how to "convert" that object to an IntPtr
so that I can pass it as the first parameter to the function. I've tried to use Marshal.StructureToPtr
but obviously this failed with an exception, since I am not passing a structure but rather just a reference to an unmanaged COM object.
So my question is:
How to successfully call the HrGetOneProp
method with passing a COM object?
You want to use the Marshal.GetIUnknownForObject Method.