Outlook staying in memory after item is displayed

Add-in Express™ Support Service
That's what is more important than anything else

Outlook staying in memory after item is displayed
 
Doug Cox




Posts: 103
Joined: 2006-10-05
I?Â?Ð?ém having trouble with Outlook staying in memory after I display an item.
Here?Â?Ð?és an example for opening an appointment item:

Private Sub LoadAppointment(ByVal eID as string, ByVal SID as string)

Dim ns As Outlook._NameSpace = Nothing
Dim ola As Outlook._AppointmentItem = Nothing
Dim oli As Outlook._Inspector = Nothing

Try
ns = OutlookApp.GetNamespace("MAPI")
ola = ns.GetItemFromID(eID, sID)
oli = ola.GetInspector
oli.Display()

Catch ex As Exception

Finally
If Not (ns Is Nothing) Then Marshal.ReleaseComObject(ns)
If Not (ola Is Nothing) Then Marshal.ReleaseComObject(ola)
If Not (oli Is Nothing) Then Marshal.ReleaseComObject(oli)
End Try

End Sub

If I comment out the oli.display() line Outlook will close normally.

I?Â?Ð?ém developing with Add-in Express 2007 and Outlook 2000.
Thanks,
Doug
Posted 26 May, 2007 11:07:38 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Doug.

Please try the following signature to display an item as a modal window:
oli.Display(True)


P.S. Note that we take up your forum requests in the order we receive them. Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found
Posted 28 May, 2007 09:08:55 Top
Doug Cox




Posts: 103
Joined: 2006-10-05
Sergey,

When I change it to oli.Display(True), the appointment displays however I can?Â?Ð?ét do anything with the it (or Outlook). It?Â?Ð?és like another model window is open so I have to shut down Outlook from task manager.

Any ideas?
Thanks,
Doug
Posted 28 May, 2007 09:55:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Doug,
Outlook 2000 can't close its inspectors automatically. So, you will have to close all inspector windows manually after the main window is closed.
Posted 28 May, 2007 10:23:06 Top
Doug Cox




Posts: 103
Joined: 2006-10-05
Sergey,
OK, thanks for the reply and I now understand that I must close the inspector window after I open it. So now my sub looks like this:


Private Sub LoadAppointment(ByVal eID as string, ByVal SID as string) 

Dim ns As Outlook._NameSpace = Nothing 
Dim ola As Outlook._AppointmentItem = Nothing 
Dim oli As Outlook._Inspector = Nothing 

Try 
ns = OutlookApp.GetNamespace("MAPI") 
ola = ns.GetItemFromID(eID, sID) 
oli = ola.GetInspector 
oli.Display(True) 
Oli.Close(Outlook.OlInspectorClose.olPromptForSave)

Catch ex As Exception 

Finally 
If Not (ns Is Nothing) Then Marshal.ReleaseComObject(ns) 
If Not (ola Is Nothing) Then Marshal.ReleaseComObject(ola) 
If Not (oli Is Nothing) Then Marshal.ReleaseComObject(oli) 
End Try 

End Sub



But I still have the same problem that when I open the appointment red I can only edit the body of the appointment (if it happens to have the focus). I cannot change the focus to another text box or click on any of the built in toolbar buttons.

So the user can not do anything with the appointment and the only way to close the appointment is from task manager or by pressing the Esc key. If I close the appointment by pressing the Esc key, then close Outlook, Outlook is still in memory.


Can you help?
Thanks,
Doug
Posted 29 May, 2007 11:36:22 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Doug.

I tested the code below in Outlook 2000 SR-1 using the latest Add-in Express version. It worked fine. What exactly should I do to reproduce the Outlook hanging.

Private Sub LoadAppointment(ByVal eID As String, ByVal SID As String)

Dim ns As Outlook._NameSpace = Nothing
Dim ola As Outlook._AppointmentItem = Nothing
Dim oli As Outlook._Inspector = Nothing

Try
ns = OutlookApp.GetNamespace("MAPI")
ola = ns.GetItemFromID(eID, SID)
oli = ola.GetInspector
oli.Display(False)

Catch ex As Exception

Finally
If Not (ns Is Nothing) Then
Marshal.ReleaseComObject(ns)
End If
If Not (ola Is Nothing) Then
Marshal.ReleaseComObject(ola)
End If
If Not (oli Is Nothing) Then
Marshal.ReleaseComObject(oli)
End If
End Try
End Sub
Posted 30 May, 2007 09:15:59 Top