Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure classification using vba

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.

like image 511
Mkrish Avatar asked Feb 27 '18 07:02

Mkrish


People also ask

Is it possible to use VBA to classify a document?

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.

How do I set an Azure Information Protection label for a file?

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.

How do I create custom classification rules in Microsoft purview?

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.

How do I create classification rules in data map?

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.


1 Answers

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
like image 135
HaPi Avatar answered Sep 26 '22 13:09

HaPi