C
Carsten Gehling
I have made an Addin for Outlook 2003 using VSTO. I want it to handle
changes to Appointment Items in the users calendar.
But I have a problem regarding handling the item-events. If you look
at the code below, I try to handle the Item's Write event, put up a
message and "cancel" the event to make sure, that the item is NOT
saved.
My problem lies in that the event-handler is not called on all save
events. The very first time I open an appointment item, changes e.g.
the Subject and press "Save" - my event-handler is called.
But on all subsequent saves, it is not called (even if I change some
of the properties)
This is my code - quite simple:
------------------------------------------------------------------------------
Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
Try
' Handle when an inspector window is opened with e.g. an appointment
item
selectInspectors = Me.Inspectors()
AddHandler selectInspectors.NewInspector, AddressOf
Me.NewInspector_Event
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub NewInspector_Event(ByVal new_Inspector As
Outlook.Inspector)
Dim appItem As Outlook.AppointmentItem
appItem = new_Inspector.CurrentItem
' Handle if items are deleted
AddHandler appItem.Write, AddressOf Me.Item_Write_Event
End Sub
Private Sub Item_Write_Event(ByRef Cancel As Boolean)
MsgBox("Don't do it")
Cancel = True
End Sub
changes to Appointment Items in the users calendar.
But I have a problem regarding handling the item-events. If you look
at the code below, I try to handle the Item's Write event, put up a
message and "cancel" the event to make sure, that the item is NOT
saved.
My problem lies in that the event-handler is not called on all save
events. The very first time I open an appointment item, changes e.g.
the Subject and press "Save" - my event-handler is called.
But on all subsequent saves, it is not called (even if I change some
of the properties)
This is my code - quite simple:
------------------------------------------------------------------------------
Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
Try
' Handle when an inspector window is opened with e.g. an appointment
item
selectInspectors = Me.Inspectors()
AddHandler selectInspectors.NewInspector, AddressOf
Me.NewInspector_Event
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub NewInspector_Event(ByVal new_Inspector As
Outlook.Inspector)
Dim appItem As Outlook.AppointmentItem
appItem = new_Inspector.CurrentItem
' Handle if items are deleted
AddHandler appItem.Write, AddressOf Me.Item_Write_Event
End Sub
Private Sub Item_Write_Event(ByRef Cancel As Boolean)
MsgBox("Don't do it")
Cancel = True
End Sub