(Msg. 1) Posted: Mon May 11, 2009 5:02 pm
Post subject: IMapiSession exception: Specified cast is not valid Archived from groups: microsoft>public>outlook>program_addins (more info?)
I'm using Mapi33... trying to get IMapiSession reference using the code
below...
(Msg. 2) Posted: Mon May 11, 2009 8:46 pm
Post subject: Re: IMapiSession exception: Specified cast is not valid [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Did you call MAPIInitialize on that thread?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"skycloud" <skycloud.TakeThisOut@discussions.microsoft.com> wrote in message
news:F2F28A20-3D10-4CDF-B5E4-0EC64440E390@microsoft.com...
> 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
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum