Stopping Outlook.exe from VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hell

I've written some code to start an Outlook session from a VB6 form; after I'm finished I do

OlApp.Qui
Set OlApp = Nothin

and return to the application's main form - but Outlook.exe is still running according to Task Manager - and I'm getting some bizarre behaviour when I then start another Outlook session from a different form - like the first form's code starts executing midway through the second form's activity. All the variables I'm using are private to the form, not global

If anyone has any ideas I'd be grateful to hear them... :-
 
As far as I can tell, your code should be closing Outlook.
Generally what causes Outlook to remain open when you try
to shut it down, is one or more references you've set to
Outlook objects, that have not been set back to Nothing.
Read over your code and make sure you are releasing all
Outlook objects.

If you're using Outlook 2002, you may be running into this
issue: http://support.microsoft.com/?kbid=294867

I have also run across situations where Outlook is set to
check mail automatically every few minutes, that closing
it from the menus or the Close Window box, doesn't
actually close it- it remains in memory. Reboot, open
Outlook without running your VB app, then close it. After
a few seconds, look in Task Manager. It could be the
problem is not your code at all, but Outlook itself.

Hope some of that helps,

-Andrew Cushen
===========================
-----Original Message-----
hello

I've written some code to start an Outlook session from a
VB6 form; after I'm finished I do
OlApp.Quit
Set OlApp = Nothing

and return to the application's main form - but
Outlook.exe is still running according to Task Manager -
and I'm getting some bizarre behaviour when I then start
another Outlook session from a different form - like the
first form's code starts executing midway through the
second form's activity. All the variables I'm using are
private to the form, not global.
 
Thanks for the input Andrew. I checked my code and changed a few suspect areas but makes no difference. Also I tried your suggestion with using Outlook stand-alone but on closing the exe also disappeared.

I then set up a new VB project with two simple forms, emulating the way I'm using Outlook in the real application, and the behaviour still occurs - ie Outlook stays in memory after myOlApp.Quit, Set myOlApp = nothing. Code is below - can you spot the problem? Thanks again for your help.

Form 1
--------

Private Sub Command1_Click()
Form2.Show vbModal, Me
End Sub

Form 2
--------

Private myOlApp As Outlook.Application
Private myNameSpace As Outlook.NameSpace
Private myFolder As Object
Private myTopFolder As Object
Private WithEvents myExplorer As Outlook.Explorer

Private Sub Command1_Click()

Set myOlApp = New Outlook.Application
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myTopFolder = myNameSpace.Folders("St Columba Calendar")
Set myFolder = myTopFolder.Folders("Calendar")
Set myExplorer = myFolder.GetExplorer(olFolderDisplayNoNavigation)
myExplorer.Display

End Sub

Private Sub myExplorer_Close()
myOlApp.Quit
Set myOlApp = Nothing
Unload Me
End Sub



----- Andrew Cushen wrote: -----

As far as I can tell, your code should be closing Outlook.
Generally what causes Outlook to remain open when you try
to shut it down, is one or more references you've set to
Outlook objects, that have not been set back to Nothing.
Read over your code and make sure you are releasing all
Outlook objects.

If you're using Outlook 2002, you may be running into this
issue: http://support.microsoft.com/?kbid=294867

I have also run across situations where Outlook is set to
check mail automatically every few minutes, that closing
it from the menus or the Close Window box, doesn't
actually close it- it remains in memory. Reboot, open
Outlook without running your VB app, then close it. After
a few seconds, look in Task Manager. It could be the
problem is not your code at all, but Outlook itself.

Hope some of that helps,

-Andrew Cushen
===========================
-----Original Message-----
hello
Outlook.exe is still running according to Task Manager -
and I'm getting some bizarre behaviour when I then start
another Outlook session from a different form - like the
first form's code starts executing midway through the
second form's activity. All the variables I'm using are
private to the form, not global.
 
You aren't releasing all your Outlook objects. In myExplorer_Close you
need to set myOlApp, myNameSpace, myFolder, myTopFolder and myExplorer
all equal to Nothing. It also wouldn't hurt to have a line
myNameSpace.Logoff before the line where you quit Outlook.




AndyK said:
Thanks for the input Andrew. I checked my code and changed a few
suspect areas but makes no difference. Also I tried your suggestion
with using Outlook stand-alone but on closing the exe also
disappeared.
I then set up a new VB project with two simple forms, emulating the
way I'm using Outlook in the real application, and the behaviour still
occurs - ie Outlook stays in memory after myOlApp.Quit, Set myOlApp =
nothing. Code is below - can you spot the problem? Thanks again for
your help.
 
Back
Top