• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

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
0
chetan_gupta
Asked:
chetan_gupta
  • 5
  • 4
1 Solution
 
nonubikCommented:
> 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.
0
 
chetan_guptaAuthor Commented:
Thanks nonubik,

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

chetan
0
 
nonubikCommented:
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
chetan_guptaAuthor Commented:
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.
0
 
nonubikCommented:
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.
0
 
chetan_guptaAuthor Commented:
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
0
 
nonubikCommented:
>Do you have any idea why this instance is not closing and why those events are not captured on closing of Ms Outlook

As I said before, I suspect that your code from the OnConnection that involves pApplication/spApp is not properly releasing the Outlook application, thus the hanging.
This has nothing to do with the fact that the code works "fine", it may seem to work as planned, but cleaning up may be a headache.

If you cannot post your code I cannot guess what you do, so I can't help you further.
0
 
chetan_guptaAuthor Commented:
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.
0
 
nonubikCommented:
Try this: comment all your code from OnConnection (except return S_OK;) and then try to see whether OnBeginShutdown is called or not.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now