Link to home
Start Free TrialLog in
Avatar of chetan_gupta
chetan_gupta

asked on

outlook addins problems

Hello all,

I am facing a problem in an application, which i m creating. What i am doing is i m creating a handle of OUTlook Express in my application as soon as OUTlook express is launched. This i did by

STDMETHOD(OnConnection)(IDispatch * Application, ext_ConnectMode ext_cm_Startup/*ConnectMode*/, IDispatch * AddInInst, SAFEARRAY * * custom)
      {
            // QueryInterface() for _Application
            CComQIPtr <Outlook::_Application> spApp(Application);
            ATLASSERT(spApp);
                          /* remaining code    */
            return S_OK;
      }

The problem I am facing is that when outlook express is closed, my corresponding function is not called. What i did is this

STDMETHOD(OnBeginShutdown)(SAFEARRAY * * custom)
      {
      // it should be called when the outlook main window is been closed.      
      return E_NOTIMPL;
      }

STDMETHOD(OnDisconnection)(ext_DisconnectMode ext_dm_HostShutdown/*RemoveMode*/, SAFEARRAY * * custom)
      {
      return E_NOTIMPL;
      }

Neither of function is getting called. Could any of you can tell what the problem is, and is there any other event to use?

Waiting for ans.

regards
Chetan
Avatar of nonubik
nonubik

> What i am doing is i m creating a handle of OUTlook Express in my application as soon as OUTlook express is launched

Are you talking here about Outlook Express or MS Outlook from MSOffice?

They are 2 different applications, the only things in common are that they both are mail clients and made by Microsoft. MSOutlook is from the Office suite and supports automation through COM. Outlook Express comes with Windows and is a light email client, does not support automation through MSOffice COM at all. That's why Outlook::_Application cannot be obtaine from an Outlook Express application.
Avatar of chetan_gupta

ASKER

Thanks nonubik,

you are right, i made mistake, it is Ms outlook. do u have ne ans. under Ms outlook.

chetan
You need to register your COM addin (if you didn't already do this). Take a look here http://www.codeproject.com/com/outlookaddin.asp
i have already registered my COM addin, and it is working fine. the problem is arising when i close my Ms outlook. My desired functions are not called and to my surprise, i also found that the instance of OUTLOOK.EXE remains in the tast manager even after i closes my MS-OUTLOOK.
I think your code is not being called because the Outlook does not close (as you said, it remains in task manager). And I suspect the omitted code from OnConnection to be guilty.
Please post what you do with 'spApp'. Remember, as it's a smartpointer you don't need to call Release or to delete it.
Well nonubik, i have checked my code it is working fine, Due to some reasons i cannot post that code over here but what i m actually doin is this...

In the onconnection Method i am putting a button on the toolbar of MS Outlook by using CommandBar Button. Afterwards on the click event of the button on toolbar i am putting a Message.Till now my code is working properly.

when i open MS outlook , my button adds on the toolbar and then the event is also getting captured. But when i close the MS Outlook, my control should go through Onshutdown or OnDisconnection event But it is not going at that point......
the thing is when i close my MS Outlook, it closes but its instance is not closing. Due to which the next time i open MS Outlook my application doesn't work. Do you have any idea why this instance is not closing and why those events are not captured on closing of Ms Outlook
ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nonubik, as u r saying that my spApp is not releasing the handle, it won't becoz i m releasing outlook's handle at on disconnection.
 
If you think that u cannot help me further.....
than thanxs for the effort you have shown till now and at any point of time (before closing of this question) you think, you can help me you are most welcome.
Try this: comment all your code from OnConnection (except return S_OK;) and then try to see whether OnBeginShutdown is called or not.