我想将约会项目从一个日历同步到另一个日历。我实现了一个ItemChange Handler,它根据特定的UserProperty更新约会。现在我想当我删除一个约会时,ItemRemove事件被触发,我可以在那里处理其他日历中的删除,但事实上,ItemChange事件首先被触发。
如何检查传递的项目是否被删除,以便我可以在ItemChange处理程序中忽略这种情况?我试图检查Null,Nothing或Empty,但Item Object是一个约会,其中大多数属性(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 :(得分:0)
这很简单:只需在垃圾文件夹中使用_ItemAdd BUT即可! e.g。
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