Outlook.exe Process continue running after Outlook 2003 closed

R

Rich Barone

I have a .NET application that interacts with Outlook. If the user starts it
before Outlook, Outlook 2003 has problems such as the reminders or rules not
working. Also, the application connects/disconnects from Outlook as needed,
yet until the application shuts down, it appears to retain a reference to
Outlook, because the Outlook.exe process continues to run until the .NET
application is shut down by the user.

Am I doing this properly?

I have defined the namespace and application globally:
Private app As Outlook.Application
Private ns As Outlook.NameSpace

Public Sub connectToOutlook()
Try
If (app Is Nothing) Then
'writeToLog("app = nothing", "connecttooutlook", False)
app = New Outlook.Application
ns = app.GetNamespace("MAPI")
ns.Logon(Type.Missing, Type.Missing, False, True)
End If
Catch ex As Exception
errorCounter = errorCounter + 1
writeToLog("Error: " & ex.Message & vbCrLf & ex.StackTrace,
"ConnectTOutlook")
Finally
End Try
End Sub

Private Sub disConnectFromOutlook()
Try
If (Not ns Is Nothing) Then
ns.Logoff()
ns = Nothing
app = Nothing
End If
Catch ex As Exception
errorCounter = errorCounter + 1
writeToLog("Error: " & ex.Message & vbCrLf & ex.StackTrace,
"disconnectFromOutlook")
Finally
End Try
End Sub
 
Top