i have an application at work which creates a new html mail message,trough the outlook client on my pc. the security policy wants me to set sensibility label each mail. i tried with this code but it doesn't work,cause the new mail message comes up without the sensitivity label.is there anybody can help me ? i don't have access do admin configuration/powershell or whatever.. thanks
Try
Dim Outlook_App As New Microsoft.Office.Interop.Outlook.Application
Dim Outlook_Message As Microsoft.Office.Interop.Outlook.MailItem
Outlook_Message = Outlook_App.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
Outlook_Message.Sensitivity = Microsoft.Office.Interop.Outlook.OlSensitivity.olConfidential
Outlook_Message.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML
Outlook_Message.Subject = "Orientamento treno " & numerotreno & " del " & Today.ToShortDateString
Outlook_Message.HTMLBody = emailTemplate
Outlook_Message.To = "[email protected]"
'con questa procedeura faccio inviare la mail dall'account che corrisponde a quest'indirizzo
Dim account As Microsoft.Office.Interop.Outlook.Account
For Each account In Outlook_App.Session.Accounts
If account.DisplayName = "[email protected]" Then
Outlook_Message.SendUsingAccount = account
Outlook_Message.Sensitivity = Microsoft.Office.Interop.Outlook.OlSensitivity.olConfidential
End If
Next
Outlook_Message.Display(False)
The MailItem.Sensitivity property returns or sets a constant in the OlSensitivity enumeration indicating the sensitivity for the Outlook item. That is a pure Outlook label and not related to Sensitivity labels and Azure Information Protection.
You need to add a user property in the following format:
Look for the
UserProperties.Addmethod for such tasks.But I'd suggest exploring internals of Outlook mail items using MFCMAPI or
OutlookSpyto find the exact solution. Try to set it manually then explore internals using these tools.