C# MailItem.MAPIOBJECT question

  • Thread starter Thread starter Codex
  • Start date Start date
C

Codex

In C# add-ins for outlook, my understanding is that the
Outlook.MailItem.MAPIOBJECT refers to an IMessage item from which we
can extract the mail headers.

Further, I understand that in other languages, you can use the
QueryInterface method to get the IMessage object from MAPIOBJECT.

C# does not have a QueryInterface method. I've tried typecasting
MAPIOBJECT to CDO.IMessage, but I get a typecast exception.

How do I get the IMessage item from Outlook.MailItem.MAPIOBJECT

Thanks,
-Codex
 
MAPIOBJECT returns an Extended MAPI IMessage, not CDO.IMessage. .Net
languages (just like the previous versions of VB) cannot use Extended MAPI.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
No, Extended MAPI can only be used from C++ or Delphi, but not from VB.
You can check whether the message has the properties you are after using
MdbView or OutlookSpy (click IMessage).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
And is there any way i can pass MAPIOBJECT from C# to C++(unmanaged), maybe write a dll and pass MAPIOBJECT to a function as a parameter?
 
Back
Top