2

I've got a need to send email within PowerShell and have all the components except the sensitivity label. For example:

$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = 'someone@co.com'
$Mail.Subject = 'Special subject'
$SigString=Get-Content "C:\Users\someone\AppData\Roaming\Microsoft\Signatures\sig.htm"
$Mail.HTMLBody = 'blah blah blah.'
$Mail.HTMLBody += $SigString
$Mail.Send()

Unfortunately when this runs I'm prompted for the sensitivity label. I thought "Sensitivity = " might work and it does allow values 0 thru 3 but that doesn't help.

Is this possible to do?

Santiago Squarzon
  • 41,465
  • 5
  • 14
  • 37
Dave
  • 33
  • 4
  • Can you please share the error? – alexzelaya Jul 15 '21 at 23:56
  • `Sensitivity` is a property of an [Outlook MailItem](https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem.sensitivity). `$Mail.Sensitivity = 0` should do it. – Theo Jul 16 '21 at 19:56
  • 1
    @Theo, I've tried $Mail.Sensitivity = 0 and values 1 thru 3 as well. Regardless of value after I hit enter to send I still get prompted for what sensitivity label I want to use. The popup comes from "Microsoft Azure Information Protection" - "This email cannot be sent without a label. Please select:" and then gives options of "Public" thru "Restricted Sensitive". – Dave Jul 21 '21 at 13:36
  • Were you able to resolve this @Dave – visleck Dec 28 '21 at 14:21
  • @visleck, unfortunately not. – Dave Dec 29 '21 at 15:22

1 Answers1

1

I also had this problem and I could not find any way to do this "outside" of an Office program as this seems to be a built-in enterprise function allowing only a given set of sensitivity labels set by your comany.

If Python can be an alternative, you this answer can automate sensitivity label setting. Alternatively, having a pre-stored template that can be copied and then edited would also work with PS.

Josep
  • 563
  • 1
  • 5
  • 12