Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Interoperability
Bulletproof Exiting Outlook (and not crashing)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Derek Hart, post: 13743794"] Shouldn't this be doing it? Class Level Dim objOutlook As Outlook.Application Subroutine Dim objNameSpace As Outlook.NameSpace Dim objFolder As Outlook.MAPIFolder Dim objItem As Outlook.MailItem InstantiateOutlook() objNameSpace = objOutlook.GetNamespace("MAPI") objFolder = objNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) objNameSpace.Logon() ' Do processing ' Release all objects Marshal.ReleaseComObject(objOutlook) Marshal.ReleaseComObject(objNameSpace) Marshal.ReleaseComObject(objFolder) Marshal.ReleaseComObject(objItem) objOutlook = Nothing objNameSpace = Nothing objFolder = Nothing objItem = Nothing ' This is the code for InstantiateOutlook Private Sub InstantiateOutlook() Try Dim canQuit As Boolean Dim olProcess As String = "Outlook.exe" Dim query As New SelectQuery("SELECT Name FROM Win32_Process WHERE name='" & olProcess & "'") Dim searcher As New ManagementObjectSearcher(query) Dim objectCollection As ManagementObjectCollection = searcher.Get() Dim collCount As Integer = objectCollection.Count searcher.Dispose() objectCollection.Dispose() searcher = Nothing objectCollection = Nothing If collCount <> 0 Then ' Outlook already running, hook into the Outlook instance objOutlook = TryCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application) If objOutlook IsNot Nothing Then canQuit = False End If Else ' Outlook not already running, start it Dim _app As New Outlook.ApplicationClass() objOutlook = DirectCast(_app, Outlook.Application) End If SecurityManager1.ConnectTo(objOutlook) SecurityManager1.DisableOOMWarnings = True Catch ex As System.Exception MessageBox.Show(ex.Message) End Try End Sub [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Interoperability
Bulletproof Exiting Outlook (and not crashing)
Top