2013-05-24 4 views
0

약속 항목을 한 일정에서 다른 일정으로 동기화하고 싶습니다. 특정 UserProperty를 기반으로 Appointments를 업데이트하는 ItemChange Handler를 구현했습니다. 이제는 Appointment를 삭제할 때 ItemRemove 이벤트가 시작되고 다른 캘린더에서 제거를 처리 할 수 ​​있다고 생각했지만 실제로는 ItemChange 이벤트가 먼저 발생합니다.Outlook 약속 - ItemChange 및 ItemRemove 이벤트

전달 된 항목이 제거되어 ItemChange 처리기에서이 사례를 무시할 수 있는지 어떻게 확인할 수 있습니까? Null, Nothing 또는 Empty를 확인하려고했으나 항목 개체가 약속 일 때 대부분의 속성 (EntryId, UserProperies, ...)에서 오류가 발생합니다.

여기에 내 질문에

Private Sub newCal_ItemChange(ByVal Item As Object) 
    Dim appointment As Outlook.appointmentItem 
    Set appointment = Item 
    If (appointment <> deleted) Then 
    ' update other calendars 
    Else 
    ' do nothing and proceed with ItemRemove Event 
    End If 
End Sub 

답변

0

을 이해하는 데 도움이 될 몇 가지 간단한 코드이며, 그것은 매우 쉽습니다 : 단지 이벤트 _ItemAdd를 사용하지만 휴지통 폴더에! 예 :

Private WithEvents trashCalendar1 As Outlook.Items 
... 
Private Sub trashCalendar1_ItemAdd(ByVal Item As Object) 
    Dim objNS As Outlook.NameSpace 
    Set objNS = Outlook.Application.GetNamespace("MAPI") 
    Dim result As Boolean 
    ' 
    result = ...'here the actual boolean sync removing function on calendar2 
       'where you'd use your custom userproperty to find the item to delete 
       'in the calendar2-related folder 
    If result Then 
     MsgBox "sync removed" 
    End If 
End Sub 
관련 문제