如何捕获我对会议邀请的回复?

Posted

技术标签:

【中文标题】如何捕获我对会议邀请的回复?【英文标题】:How to trap my reply to a Meeting Invite? 【发布时间】:2020-08-21 14:21:18 【问题描述】:

当我回复发送到我的非默认电子邮件帐户之一的会议邀请时,Outlook 会从默认帐户而不是邀请发送到的帐户发送回复。

我尝试使用ItemLoad 事件来捕获这种情况并设置MailItem 对象以在MailItem.Reply 事件中使用。我在Set NonDefaultMailboxMtgMsg = myObj 下方的这行代码中收到类型错误消息。

如何将NonDefaultMailboxMtgMsg 设置为会议请求对应的MailItem 对象,以便触发回复事件?

Public WithEvents NonDefaultMailboxMtgMsg As MailItem
Dim MeetingReplyDisplayName As String


Private Sub Application_ItemLoad(ByVal Item As Object)
    
    Dim myObj As Variant
    Set myObj = GetCurrentItem()
      
    If myObj.Class = olMeetingRequest And myObj.Parent.Store.DisplayName _
     <> Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Store.DisplayName Then
     
        Set NonDefaultMailboxMtgMsg = myObj
        MeetingReplyDisplayName = myObj.Parent.Store.DisplayName
    End If
End Sub

Private Sub NonDefaultMailboxMtgMsg_Reply(ByVal Response As Object, Cancel As Boolean)
        Response.SendUsingAccount = MeetingReplyDisplayName
End Sub

Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application
         
    Set objApp = Application
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    End Select
     
    Set objApp = Nothing
End Function

【问题讨论】:

当您回复MeetingItem 时,您不应该使用MeetingItem_Reply 事件而不是MailItem 吗? Set NonDefaultMailboxMtgMsg = myObj 失败,因为 myObj 被检查为 olMeetingRequest 什么是 MeetingItem 而不是 MailItem 谢谢。我最初尝试将NonDefaultMailboxMtgMsg 定义为MeetingItem,但后来Private Sub NonDefaultMailboxMtgMsg_Reply(ByVal Response As Object, Cancel As Boolean) 从未被触发。上面的定义不会使它成为MeetingItem_Reply 事件吗? 代码必须在ThisOutlookSession***.com/questions/24029515/… 感谢您的链接。我确实在ThisOutlookSession 中有我的代码,但没有设置Outlook.Inspectors 来捕获回复事件。我会试试的。 【参考方案1】:

收到的项目类型是一个会议请求 (olMeetingRequest),它是一个 MeetingItem。

Public WithEvents NonDefaultMailboxMtgMsg As MailItem 不匹配,所以Set NonDefaultMailboxMtgMsg = myObj 出现类型不匹配。

改为使用Public WithEvents NonDefaultMailboxMtgMsg As MeetingItem


演示点击响应然后回复时触发事件的示例代码。

Public WithEvents NonDefaultMailboxMtgMsg As MeetingItem

Dim MeetingReplyDisplayName As String

Private Sub Application_ItemLoad(ByVal Item As Object)
    
    Debug.Print
    Debug.Print "Procedure.......: Application_ItemLoad"
    Debug.Print " TypeName(Item).: " & TypeName(Item)
    
    Dim myObj As Object
    Set myObj = GetCurrentItem()
    Debug.Print " TypeName(myObj): " & TypeName(myObj)
    
    If myObj.Class = olMeetingRequest Then
        If myObj.Parent.Store.DisplayName <> GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Store.DisplayName Then
            Set NonDefaultMailboxMtgMsg = myObj
            MeetingReplyDisplayName = myObj.Parent.Store.DisplayName
        End If
    End If
    
End Sub

Private Sub NonDefaultMailboxMtgMsg_Reply(ByVal Response As Object, Cancel As Boolean)
    Debug.Print
    Debug.Print "Procedure.........................: NonDefaultMailboxMtgMsg_Reply"
    Debug.Print " TypeName(NonDefaultMailboxMtgMsg): " & TypeName(NonDefaultMailboxMtgMsg)
    Debug.Print " TypeName(Response)...............: " & TypeName(Response)
    MsgBox "Reply event triggered"
End Sub

Function GetCurrentItem() As Object
    
    Select Case TypeName(ActiveWindow)
    
        Case "Explorer"
            On Error Resume Next
            Set GetCurrentItem = ActiveExplorer.Selection.Item(1)
            On Error GoTo 0
            
        Case "Inspector"
            Set GetCurrentItem = ActiveInspector.currentItem
            
    End Select
     
End Function

【讨论】:

我使用Public WithEvents NonDefaultMailboxMtgMsg As MailItem时,回复会议时不会触发子NonDefaultMailboxMtgMsg_Reply 我建议您提出的问题已得到回答,但您提出了错误的问题。 docs.microsoft.com/en-us/office/vba/api/… 展示了如何发送对会议请求的响应。

以上是关于如何捕获我对会议邀请的回复?的主要内容,如果未能解决你的问题,请参考以下文章

如何在Bluemix Node-Red Application中发送会议邀请(日历)[关闭]

outlook会议邀请添加收件人

怎么开腾讯视频会议

Lync 项目经验-15-配置会议邀请中企业信息

使用收件箱中的会议邀请

自动接受会议邀请