PowerShell - Set Azure Information Protection (AIP) while sending email using outlook & PowerShell

666 Views Asked by At

I am trying to send an email using PowerShell and outlook.

$Outlook = New-Object -ComObject Outlook.Application

While sending an email AIP box pops up for selecting a label.

Is there a way to set labels programmatically using PowerShell?

Thanks.

2

There are 2 best solutions below

0
On

Yes, there is. You need to add a user property in the following format:

"MSIP_Label_" & guid_internal_use_only & "_Enabled"

But I'd suggest exploring internals of Outlook mail items using MFCMAPI or OutlookSpy to find out the exact solution. So, try to set assign an AIP label manually then explore internals using these tools.

0
On

Two remarks:

  1. Regarding answer of Eugene, I was able to find my AIP label guid by inspecting internal headers for a sent E-Mail -> double click -> File -> Properties. However, I have not actually tried replicating the MSIP_Label_guid_Enabled setting.

  2. What worked for me was creating a new E-Mail in Outlook, setting the AIP label via Outlook GUI directly, then saving it somewhere as template_<Label>.msg. Then, you can use $outlook.CreateItemFromTemplate('<Full_path>/template_<Label>.msg') and when you send that E-Mail, it will already reuse the set AIP label and not prompt as usual.