【问题标题】:Set MailItem.Sensitivity of email docked in main window设置停靠在主窗口中的电子邮件的 MailItem.Sensitivity
【发布时间】:2019-08-31 03:36:27
【问题描述】:

在 Outlook 2016 停靠时尝试设置活动 MailItem 的敏感度时出现以下错误。弹出电子邮件时,我的代码的“Else”部分有效。

Error message: 
Run-time error "-2082340855 (83e20009)

该对象不支持此方法。

您可以从我附加的屏幕截图中清楚地看到 msg 变量显然是一个“MailItem”。

更新:这是工作代码:

Sub ToggleConfidentialSensitivity()
    On Error Resume Next

    Dim msg As Outlook.MailItem

    If Application.ActiveInspector Is Nothing Then 'we are in the main window (inline)
        Set msg = Application.ActiveExplorer.ActiveInlineResponse
    Else 'we are in a popped out message
        Set msg = ActiveInspector.CurrentItem
    End If

    If msg.Sensitivity = olConfidential Then
        msg.Sensitivity = olNormal
        msg.Subject = Replace(msg.Subject, "*Confidential* ", "")
        MsgBox ("This email is now marked as public")
    Else
        msg.Sensitivity = olConfidential
        msg.Subject = "*Confidential* " + msg.Subject
        MsgBox ("This email is now marked as Confidential")
    End If
End Sub

【问题讨论】:

    标签: vba outlook outlook-2016


    【解决方案1】:

    Dim msg 移到 if 语句之外。

    如果您发布您的代码以便我们运行测试将会很有帮助。

    试试 Select Case 例子

    Select Case Application.ActiveWindow.Class
           Case olExp
                Set Msg = ActiveExplorer.selection.Item(1)
           Case olInsp
                Set msg = ActiveInspector.CurrentItem
    End Select
    

    【讨论】:

    • 感谢您的建议。我会尝试一下。我用我的代码更新了我的问题,以便您/其他人可以测试。
    【解决方案2】:

    “停靠”是指内联回复吗?在这种情况下,您需要使用Application.ActiveExplorer.ActiveInlineResponse 来检索正在组合的MailItem 对象。

    【讨论】:

    • 是的,内联回复。我会试一试,然后转回来。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    相关资源
    最近更新 更多