使用宏拒绝和删除 Outlook 中的会议请求

Decline and delete Meeting request in Outlook using macro

我正在尝试创建一个一键式解决方案,以拒绝并删除我们团队成员发出的所有“我从下午 2 点到下午 3 点不在家”的会议请求(这会阻止每个人的日历)。

想法是创建一个宏,它将拒绝当前 selected 的会议请求并在没有任何提示的情况下将其删除。

Sub DeclineAndDelete()

    Dim cAppt As AppointmentItem
    Set cAppt = Application.ActiveExplorer.Selection.Item(1).GetAssociatedAppointment(True)
    
    MsgBox cAppt.Subject
    
    Dim oResponse As MeetingItem
    Set oResponse = cAppt.Respond(olMeetingDeclined, False)
    oResponse.Delete ' <---- oResponse is set to Nothing'
    cAppt.Delete

    MsgBox "Ho"
    
    Set cAppt = Nothing
    Set oResponse = Nothing

End Sub

当我 select 我的收件箱中的会议请求和 运行 宏时,它会弹出一个消息框,其中包含我 select 编辑的会议请求(MsgBox cAppt.Subject).但是在调试时它显示 cAppt.Respond 返回 Nothing.

MsgBox "Ho" 永远不会弹出。

为此,我尝试将 olMeetingDeclined 更改为 olMeetingAccepted,但没有任何区别。

我读过这个 Auto-Decline Meeting Invite Run-Time Error 91: Object variable or With block variable not set but according to documentation Respond is supposed to return 不是 Nothing 的东西。


编辑:似乎 cAppt.Respond() returns Nothing 当会议组织者要求不回应时。

在其他情况下,响应是 requested/allowed,宏实际上工作正常!

我知道这是旧的,但你的代码大部分都有效。

您只需发送响应(并更改为“True”!)

Dim oResponse As MeetingItem
Set oResponse = cAppt.Respond(olMeetingDeclined, True)
oResponse.Send

并且,不是删除回复,而是删除项目;

Application.ActiveExplorer.Selection.Item(1)