none
Subject of exception not being saved RRS feed

  • Question

  • Hi,

    I created a recurring appointment, at some point there will be some exception in that appointment as well.

    When i open the whole series for editing subject,when i save appointment my addin code does following when i save appointment.

    Public WithEvents AppItem As Outlook.AppointmentItem
    
    
    Private Sub AppItem_Write(ByRef Cancel As Boolean) Handles AppItem.Write
    
    
    	If AppItem.IsRecurring And (PrevLocation <> AppItem.Location Or SubjectChange) Then
    		Dim rp As Outlook.RecurrencePattern = Nothing
    		rp = AppItem.GetRecurrencePattern()
    		If rp.Exceptions.Count > 0 Then
    			Dim exceptions As Outlook.Exceptions = rp.Exceptions
    			Dim rpex As Outlook.Exception = Nothing
    			Dim exception As Outlook.AppointmentItem = Nothing
    			Dim e As Int16
    			For e = 1 To exceptions.Count
    				rpex = exceptions(e)
    				If (Not rpex.Deleted) Then
    					exception = rpex.AppointmentItem
    					If (PrevLocation <> AppItem.Location) Then
    						exception.Location = AppItem.Location
    					ElseIf (SubjectChange) Then
    						exception.Subject = AppItem.Subject
    					End If
    					exception.Save()
    				End If
    				NAR(exception)
    				NAR(rpex)
    			Next
    		End If
    	NAR(rp)
    	End If
    End sub
    

    When i modify the subject of the whole series, with or without above code , user interface shows correct subject for the exception as well, but when i debug this code subject of exception is still previous one , so i am trying to save them, but even adding that code  do not save subject property of item immidiately.

    What i was expecting when change event will fire after this it should get the updated subject for a particular exception, which its not doing

    It does  after some time when number of change events fires.which means whether i  use or not use above code will not make any difference

    Is there any reason why its not updating immidiately?

    Thanks

    Thursday, February 16, 2012 10:13 AM

Answers

  • Set a flag and only consider the data as valid when Unload() fires and the flag has been set. If you have an EntryID for the item you can get a reference to it later when the data is valid, then you can read the properties. That would be related to what Bill mentioned about a workaround being less real time.
     
    If you have an item reference to the item, see if calling GetInspector() on the item prevents the problem from occurring at all. It might change the behavior to what you see where it works. It might help, it's just an idea.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Nitrup" <=?utf-8?B?Tml0cnVw?=> wrote in message news:86704ff9-bd38-47d5-91ae-f981632cbc85...

    Hi ken,

    but as per documentation, An error occurs if any property or method for the item called within the Unload event.

    so do not know, how i will i use this to get updated value?

    Thanks


    Ken Slovak MVP - Outlook
    Thursday, February 16, 2012 9:37 PM
    Moderator

All replies

  • Sounds like the other problems you've been having with cached values, no?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Nitrup" <=?utf-8?B?Tml0cnVw?=> wrote in message news:96cb66e0-debe-4db0-bd14-80f38597e621...

    Hi,

    I created a recurring appointment, at some point there will be some exception in that appointment as well.

    When i open the whole series for editing subject,when i save appointment my addin code does following when i save appointment.

    Public WithEvents AppItem As Outlook.AppointmentItem
    
    
    Private Sub AppItem_Write(ByRef Cancel As Boolean) Handles AppItem.Write
    
    
    	If AppItem.IsRecurring And (PrevLocation <> AppItem.Location Or SubjectChange) Then
    		Dim rp As Outlook.RecurrencePattern = Nothing
    		rp = AppItem.GetRecurrencePattern()
    		If rp.Exceptions.Count > 0 Then
    			Dim exceptions As Outlook.Exceptions = rp.Exceptions
    			Dim rpex As Outlook.Exception = Nothing
    			Dim exception As Outlook.AppointmentItem = Nothing
    			Dim e As Int16
    			For e = 1 To exceptions.Count
    				rpex = exceptions(e)
    				If (Not rpex.Deleted) Then
    					exception = rpex.AppointmentItem
    					If (PrevLocation <> AppItem.Location) Then
    						exception.Location = AppItem.Location
    					ElseIf (SubjectChange) Then
    						exception.Subject = AppItem.Subject
    					End If
    					exception.Save()
    				End If
    				NAR(exception)
    				NAR(rpex)
    			Next
    		End If
    	NAR(rp)
    	End If
    End sub
    

    When i modify the subject of the whole series, with or without above code , user interface shows correct subject for the exception as well, but when i debug this code subject of exception is still previous one , so i am trying to save them, but even adding that code  do not save subject property of item immidiately.

    What i was expecting when change event will fire after this it should get the updated subject for a particular exception, which its not doing

    It does  after some time when number of change events fires.which means whether i  use or not use above code will not make any difference

    Is there any reason why its not updating immidiately?

    Thanks


    Ken Slovak MVP - Outlook
    Thursday, February 16, 2012 2:15 PM
    Moderator
  • looks like :-)

    is there anyway to get rid of cached values?

    Thanks 

    Thursday, February 16, 2012 3:32 PM
  • Only time:(
     
    The item.Unload() event should signal when that occurs, but as far as I know you can't force an unload when you want one.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Nitrup" <=?utf-8?B?Tml0cnVw?=> wrote in message news:1c5a7786-93f6-4e7c-a8ac-9e3f6aef878c...

    looks like :-)

    is there anyway to get rid of cached values?

    Thanks 


    Ken Slovak MVP - Outlook
    Thursday, February 16, 2012 4:36 PM
    Moderator
  • Hi ken,

    but as per documentation, An error occurs if any property or method for the item called within the Unload event.

    so do not know, how i will i use this to get updated value?

    Thanks

    Thursday, February 16, 2012 9:17 PM
  • Set a flag and only consider the data as valid when Unload() fires and the flag has been set. If you have an EntryID for the item you can get a reference to it later when the data is valid, then you can read the properties. That would be related to what Bill mentioned about a workaround being less real time.
     
    If you have an item reference to the item, see if calling GetInspector() on the item prevents the problem from occurring at all. It might change the behavior to what you see where it works. It might help, it's just an idea.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Nitrup" <=?utf-8?B?Tml0cnVw?=> wrote in message news:86704ff9-bd38-47d5-91ae-f981632cbc85...

    Hi ken,

    but as per documentation, An error occurs if any property or method for the item called within the Unload event.

    so do not know, how i will i use this to get updated value?

    Thanks


    Ken Slovak MVP - Outlook
    Thursday, February 16, 2012 9:37 PM
    Moderator