当我尝试设置停靠在Outlook 2016中的活动MailItem的灵敏度时遇到以下错误。当弹出电子邮件时,代码的“其他”部分有效。
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
答案 0 :(得分:1)
将Dim msg
移动到if语句之外。
如果您发布代码以便我们可以运行测试,将会很有帮助。
尝试类似“选择案例”示例
Select Case Application.ActiveWindow.Class
Case olExp
Set Msg = ActiveExplorer.selection.Item(1)
Case olInsp
Set msg = ActiveInspector.CurrentItem
End Select
答案 1 :(得分:1)
通过“停靠”,您是指内联回复吗?在这种情况下,您需要使用Application.ActiveExplorer.ActiveInlineResponse
来检索组成的MailItem
对象。