C
c2t5Y2xvdWQ
I'm using Mapi33... trying to get IMapiSession reference using the code
below...
IntPtr iunknownPtr =
Marshal.GetIUnknownForObject(m_OutlookApp.Session.MAPIOBJECT);
IMAPISession imapiSession = (IMAPISession)iunknownPtr;
where m_OutlookApp is an instance of Application from MS.Office.InterOp...
When I run this code inside Outlook via Addin passing m_OutlookApp from
OnConnection... it runs fine,
when I run it from command app, passing an instance of m_OutlookApp using
new Application() I get:
System.InvalidCastException was caught Message="Specified cast is not
valid."
Any idea why or a workaround on how to get an IMapiSession reference from
command line app?
Thanks in advance
below...
IntPtr iunknownPtr =
Marshal.GetIUnknownForObject(m_OutlookApp.Session.MAPIOBJECT);
IMAPISession imapiSession = (IMAPISession)iunknownPtr;
where m_OutlookApp is an instance of Application from MS.Office.InterOp...
When I run this code inside Outlook via Addin passing m_OutlookApp from
OnConnection... it runs fine,
when I run it from command app, passing an instance of m_OutlookApp using
new Application() I get:
System.InvalidCastException was caught Message="Specified cast is not
valid."
Any idea why or a workaround on how to get an IMapiSession reference from
command line app?
Thanks in advance