我想将约会项目从一个日历同步到另一个日历。我实现了一个基于特定UserProperty更新约会的ItemChange处理程序。现在,我想当我删除一个约会时,ItemRemove事件被触发,我可以处理其他日历中的删除,但事实上,ItemChange事件首先被触发。
如何检查传递的项是否已删除,以便在ItemChange处理程序中忽略这种情况?我尝试检查Null、Nothing或Empty,但Item对象是一个约会,其中大多数属性(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发布于 2013-10-16 18:57:51
这很简单:只需使用事件_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 Subhttps://stackoverflow.com/questions/16730658
复制相似问题