【问题标题】:Outlook Appointment - ItemChange and ItemRemove EventOutlook 约会 - ItemChange 和 ItemRemove 事件
【发布时间】:2020-06-25 17:00:35
【问题描述】:

我想将约会项目从一个日历同步到另一个日历。我实现了一个 ItemChange 处理程序,它根据特定的 UserProperty 更新约会。现在我想,当我删除一个约会时,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

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    这很简单:只需在垃圾文件夹上使用事件 _ItemAdd BUT! 例如

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-06
      • 2015-09-03
      • 2018-08-13
      相关资源
      最近更新 更多