Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / December 2004

Tip: Looking for answers? Try searching our database.

Cannot create instance of the interface 'Application'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcus Eklund - 15 Dec 2004 18:15 GMT
I am following
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/ht
ml/ol03csharp.asp


Trying to use the NewMailEx function but i keep getting an error on this
 code

Application outLookApp = new Application();

Cannot create instance of the interface 'Application'

I have the reference and all, i can't figure out what the error is and i
am going bald with all the hairpulling i have been doing due to this.

Please help me,
Best regards
Marcus
Mark Beiley - 16 Dec 2004 15:48 GMT
Hi Marcus,

I don't think you want to create a "new" application.  You probably just
want to get a pointer to the existing application.  I'm not sure how to do
this in csharp, but here is some C++ code from an Outlook add-in to
accomplish this:

HRESULT BSAddIn::GetOutlookApp(IExchExtCallback   *pmecb,
       Outlook::_ApplicationPtr  &rOLAppPtr)
{
  try
  {
  IOutlookExtCallback *pOutlook = NULL;
     HRESULT hRes = pmecb->QueryInterface(IID_IOutlookExtCallback,(void **)
&pOutlook);
     if (pOutlook)
     {
        IUnknown *pUnk = NULL;
        pOutlook->GetObject(&pUnk);
        LPDISPATCH lpMyDispatch;
        if (pUnk != NULL)
        {
           hRes = pUnk->QueryInterface(IID_IDispatch, (void **)
&lpMyDispatch);
  pUnk->Release();
        }
        if (lpMyDispatch)
        {
           OLECHAR * szApplication = L"Application";
  DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
  DISPID dspid;
  VARIANT vtResult;
  lpMyDispatch->GetIDsOfNames(IID_NULL, &szApplication, 1,
LOCALE_SYSTEM_DEFAULT, &dspid);
  lpMyDispatch->Invoke(dspid, IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD, &dispparamsNoArgs, &vtResult, NULL, NULL);
  lpMyDispatch->Release();

  rOLAppPtr= vtResult.pdispVal;
             return S_OK;
        }
     }
  }
  catch(...)
  {
  }
  return S_FALSE;
}

Mark
http://www.email-announcer.com

>I am following
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/ht
ml/ol03csharp.asp

[quoted text clipped - 12 lines]
> Best regards
> Marcus
Marcus Eklund - 16 Dec 2004 16:35 GMT
Hi Mark,

Thanks for the answer.
I just solved it, a bit father down in that webpage i was reading, they
said what to use instead of Application. You had to use ApplicationClass
and it worked fine.

/Marcus

> Hi Marcus,
>
[quoted text clipped - 47 lines]
> Mark
> http://www.email-announcer.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.