A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

my first outlook add-in, in c++...



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 16th 06, 12:02 AM posted to microsoft.public.outlook.program_addins
optimist
external usenet poster
 
Posts: 8
Default my first outlook add-in, in c++...

And I'm apparently suffering from a common problem - how to get Outlook to
shutdown after my add-in is installed. I've flailed for a couple of days,
now it's time to ask for help. I've gleaned that I need to somehow close or
release or free something in the OnClose event for the Explorer, but what and
how is that done? I've tried doing
appPtr-GetApplication()-Release()...which doesn't seem to have any effect.
Here's the OnConnection() code where some of the initialization code lives,
if it helps to point out my failures...

STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
AddInDesignerObjects::ext_ConnectMode ConnectMode, IDispatch *pAddInInst,
SAFEARRAY ** /*custom*/ )
{
pApplication-QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pApplication);

CComQIPtr Outlook::_Application spApp(pApplication);
ATLASSERT(spApp);
m_spApp = spApp;

CComPtrOutlook::_Explorer spExplorer;

spExplorer = spApp-ActiveExplorer();
m_spExplorer = spExplorer;

ExpEvents:ispEventAdvise((IDispatch*)m_spExplore r,&__uuidof(Outlook::ExplorerEvents));

AppEvents:ispEventAdvise((IDispatch*)m_spApp,&__ uuidof(Outlook::ApplicationEvents));

return S_OK;
}
  #2  
Old May 16th 06, 03:26 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default my first outlook add-in, in c++...

In On_Connection you first need to check if there are any Explorers at all,
Outlook can be started using automation with no UI (think ActiveSynch). You
need to maintain a count or collection of Explorers and Inspectors and
handle the Inspector.Close and Explorer.Close events. In those events if the
counts of the collections is = 1 you know Outlook wants to close down. At
that point you need to release all objects that are being retained so the
On_Disconnection event will fire.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"optimist" wrote in message
...
And I'm apparently suffering from a common problem - how to get Outlook to
shutdown after my add-in is installed. I've flailed for a couple of
days,
now it's time to ask for help. I've gleaned that I need to somehow close
or
release or free something in the OnClose event for the Explorer, but what
and
how is that done? I've tried doing
appPtr-GetApplication()-Release()...which doesn't seem to have any
effect.
Here's the OnConnection() code where some of the initialization code
lives,
if it helps to point out my failures...

STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
AddInDesignerObjects::ext_ConnectMode ConnectMode, IDispatch *pAddInInst,
SAFEARRAY ** /*custom*/ )
{
pApplication-QueryInterface(__uuidof(IDispatch),
(LPVOID*)&m_pApplication);

CComQIPtr Outlook::_Application spApp(pApplication);
ATLASSERT(spApp);
m_spApp = spApp;

CComPtrOutlook::_Explorer spExplorer;

spExplorer = spApp-ActiveExplorer();
m_spExplorer = spExplorer;

ExpEvents:ispEventAdvise((IDispatch*)m_spExplore r,&__uuidof(Outlook::ExplorerEvents));

AppEvents:ispEventAdvise((IDispatch*)m_spApp,&__ uuidof(Outlook::ApplicationEvents));

return S_OK;
}


  #3  
Old May 16th 06, 04:03 PM posted to microsoft.public.outlook.program_addins
optimist
external usenet poster
 
Posts: 8
Default my first outlook add-in, in c++...

"Ken Slovak - [MVP - Outlook]" wrote:

In On_Connection you first need to check if there are any Explorers at all,
Outlook can be started using automation with no UI (think ActiveSynch). You
need to maintain a count or collection of Explorers and Inspectors and
handle the Inspector.Close and Explorer.Close events. In those events if the
counts of the collections is = 1 you know Outlook wants to close down. At
that point you need to release all objects that are being retained so the
On_Disconnection event will fire.


That's one of the problems I'm looking for help on - how to "release" the
objects...
In my OnConnection I'm saving a pointer to the Application and
ActiveExplorer objects - I haven't yet figured out why my NewExplorer
callback hasn't been triggered but since in my testing I only have the one
instance of outlook running I figured that wasn't too surprising - anyway, in
my OnClose() I'm calling Release() on the application object
(m_spApp-GetApplication()-Release() but if I try to call Release on the
explorer object (m_spExplorer-Release(), I get a 'cannot access private
member declared in class ...
error from the compiler. I got the same error from the release of the
application before I found the GetApplication() method. What's the correct
way to "release" the objects?
  #4  
Old May 16th 06, 05:44 PM posted to microsoft.public.outlook.program_addins
optimist
external usenet poster
 
Posts: 8
Default my first outlook add-in, in c++...

I found the problem - I created another app instance in my
OnStartupComplete, once I removed that I'm now getting the OnDisconnect.
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add 10 attendees in outlook ? manatee Outlook - Calandaring 2 May 23rd 06 06:16 PM
How to add dynamically add controls in Outlook 2003 Rahul Outlook and VBA 5 May 8th 06 03:38 PM
How to add dynamically add controls in Outlook 2003 Sue Mosher [MVP-Outlook] Outlook - Using Forms 4 May 8th 06 03:38 PM
Uninstall Outlook add-in KPowell Add-ins for Outlook 1 February 15th 06 10:55 PM


All times are GMT +1. The time now is 08:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.