![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
Did you call MAPIInitialize on that thread?
-- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "skycloud" wrote in message ... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unable to cast COM object" error | Emrak | Outlook - Using Forms | 2 | May 1st 09 07:49 AM |
Unable to cast COM object" error | Emrak | Add-ins for Outlook | 5 | April 30th 09 07:01 PM |
Specified cast is not valid | Janni | Add-ins for Outlook | 1 | April 8th 09 02:57 PM |
Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass' | John Yovas | Add-ins for Outlook | 2 | September 12th 08 04:23 PM |
Usage of IMAPISession from IExchExt | Petr Nehez | Add-ins for Outlook | 1 | December 12th 06 04:40 PM |