I am getting the following error when trying to set the Sensitivity of the active MailItem when docked in Outlook 2016. The "Else" part of my code works when the email is popped out.
Error message:
Run-time error "-2082340855 (83e20009)
The object does not support this method.
You can clearly see from my attached screenshot that the msg variable is clearly a "MailItem".
UPDATE: Here is the working code:
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