I have a macro that creates and saves multiple word and excel documents. Recently, My organisation started using Microsoft Azure protection. It always asks the user to choose the classification label while saving the document. Is there a way we can pass the label from VBA? (i.e. controlling the classification via code)
I tried to search the existing questions and had no luck.
The object is available in VBA, just can't find any example on how to use it. Hi, This is a Microsoft 365 subscription feature. There is a button in the home ribbon which allow you to classify your document. The object is available in VBA, just can't find any example on how to use it. Interesting. I know nothing about this feature.
Scans a file to automatically set an Azure Information Protection label for a file, according to conditions that are configured in the policy. The Set-AIPFileClassification cmdlet can automatically apply a label for one or more files when you configure labels for automatic classification.
The Microsoft Purview governance portal supports the following two methods for creating custom classification rules: Use the Regular expression (regex) method if you can consistently express the data element by using a regular expression pattern or you can generate the pattern by using a data file.
The formal names of system classifications have a MICROSOFT prefix. Create a custom classification name, if necessary. Start on this pane, and then go to Data Map > Annotation management > Classification rules. Here, you can create the classification rule for the custom classification name that you created in the preceding step.
It seems that after more than a year there is still no solution. At least I did not find any native VBA integration for AIP.
However I found a solution for myself. Basically I create now a draft of a mail manually where I choose the classification manually. This draft remains in a special folder in outlook. Once I need to send a mail via VBA I copy the draft (classification included!), I change recipients, object, body and I am able to send it without user interaction from VBA since the classification is already done.
Private Sub Email()
Dim oMailItem As Outlook.MailItem
'Set oMailItem = Outlook.Application.CreateItem(olMailItem)
'Choose template according to subject
'I have one template for each sensitivity classification
Set oMailItem = getVbaTemplateMail("VBA Template - Sensitivity=General")
With oMailItem
.To = "[email protected]"
.subject = "Email Test using VBA"
.Body = "Test"
.Display
.Send
End With
Set oMailItem = Nothing
End Sub
Private Function getVbaTemplateMail(subject As String) As Outlook.MailItem
Dim olFolder As Outlook.MAPIFolder
Dim olItem As Outlook.MailItem
'GetDefaultFolder(16) = Draft folder, "Drafts/VBA Templates" is my VBA Template folder
Set olFolder = Application.GetNamespace("MAPI").GetDefaultFolder(16).Folders("VBA Templates")
For Each olItem In olFolder.Items
Debug.Print olItem.subject ' Print to immediate window
If olItem.subject = subject Then
Set getVbaTemplateMail = olItem.Copy
'If error "Active Inline Response" appears, the mail is open in Outlook, close it first!
Exit Function
End If
Next
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With