我怎么能默默地拒绝会议呢?

时间:2013-08-02 20:31:02

标签: outlook-vba

我目前有一个脚本,我与规则绑定,以便我可以自动拒绝某些主题的会议请求:

Sub AutoDeclineMeetings(oRequest As MeetingItem)

If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then
  Exit Sub
End If

Dim oAppt As AppointmentItem
Set oAppt = oRequest.GetAssociatedAppointment(True)

Dim oResponse
 Set oResponse = oAppt.Respond(olMeetingDeclined, True)
 oResponse.Send

End Sub

然而,这会向会议组织者发回一个回应,这会对他们造成不必要的反应,因为他们不在乎我是否参加。

如何更改此代码,以便会议不会显示在我的日历中,从而不会发送任何回复?我尝试过简单地同时调用oAppt.DeleteoRequest.Delete,但这不会从我的日历中删除该项目。

有效地,我正在寻找的相当于手动选择拒绝 - &gt;不会在会议请求中发送回复

2 个答案:

答案 0 :(得分:1)

而不是oResponse.Send,请尝试oResponse.Close(olDiscard)

答案 1 :(得分:-1)

删除回复而不是发送回复:

oResponse.Delete代替oResponse.Send

Sub DeclineSelected()
    Dim Session As Outlook.NameSpace
    Dim currentExplorer As Explorer
    Dim Selection As Selection
    Dim currentItem As Object
    Dim oAppt As AppointmentItem
    Dim oResponse

    Set currentExplorer = Application.ActiveExplorer
    Set Selection = currentExplorer.Selection

    'For all items selected...
    For Each currentItem In Selection
        'If it is a meeting request...
        If currentItem.MessageClass = "IPM.Schedule.Meeting.Request" Then
            Set oAppt = currentItem.GetAssociatedAppointment(True)
            If oAppt.ResponseRequested Then
                Set oResponse = oAppt.Respond(olMeetingDeclined, True, False)
                oResponse.Delete
            Else
                Set oResponse = oAppt.Respond(olMeetingDeclined, True, False)
            End If
            currentItem.Delete

        'If it is a meeting cancellation...
        ElseIf currentItem.MessageClass = "IPM.Schedule.Meeting.Canceled" Then
            Set oAppt = currentItem.GetAssociatedAppointment(True)
            If oAppt Is Nothing Then
                currentItem.Delete
            End If

    'Delete if just an email...
        ElseIf currentItem.MessageClass = "IPM.Note" Then
            currentItem.Delete
        End If

    Next
End Sub