【问题标题】:Decline and delete Meeting request in Outlook using macro使用宏在 Outlook 中拒绝和删除会议请求
【发布时间】:2021-07-29 00:09:07
【问题描述】:

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

想法是创建一个宏,该宏将拒绝当​​前选择的会议请求并将其删除而无需任何提示。

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

当我在收件箱中选择会议请求并运行宏时,它会弹出一个消息框,其中包含我选择的会议请求的主题 (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,但根据文档Respond is supposed to return,这不是Nothing


编辑:当会议组织者要求不回复时,cAppt.Respond() 似乎返回了Nothing

在请求/允许响应的其他情况下,宏实际上可以正常工作!

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    我知道这很旧,但你的代码大部分都可以工作。

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

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

    并且,不是删除响应,而是删除项目;

    Application.ActiveExplorer.Selection.Item(1)
    

    【讨论】:

    • 谢谢!我试图将其更改为True。但是cAppt.Respond() 仍然没有返回任何内容。 oResponse.Send 炸弹因为 oResponse 未设置。我也不想发送回复。只是希望它从我的日历和收件箱中消失。
    • 我不想这么说,但你确定它是“无”吗?或者当你运行“oResponse.Delete”时它只是给出一些奇怪的自动化错误?这是 API 调用 - docs.microsoft.com/en-us/office/vba/api/…
    • 我做了一步步调试,在监视窗口中是“Nothing”。无论如何,刚从我的假期回来,它的工作原理!我不知道我改变了什么,没有任何 AFAIK。不过还是谢谢你。
    • 当会议组织者要求不回复时,cAppt.Respond() 似乎返回了Nothing。否则它会起作用。
    猜你喜欢
    • 2017-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多