Reading internet headers set in an Outlook email by Azure Information Protection Unified Labeling Client

1

I am using Azure Information Protection Unified Labeling client to label emails. We are still using PGP in our environment and emails classified strictly confidential must be PGP encrypted.

When the email is sent, I try to find out, how the email is classified and trigger PGP encryption, when the classification is strictly confidential. This is done in an Outlook VSTO c# Add-in.

To find out the classification, I read the email header property "msip_labels" which is set by AIP and contains all necessary information. I am using the following procedure to read the headers. The code is far away from being perfect. I am just figuring out, how to get the value.:

private void GetHeaders()
{
    var mail = (Outlook.MailItem)Application.ActiveInspector().CurrentItem;
    var propertyAccessor = mail.PropertyAccessor;
    try
    {
        var custom = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/msip_labels");
    }
    catch(Exception ex) 
    {
        var message = ex.Message;
    }
}

I am able to read properties, set by another tool, but the AIP property is multiline. When the code is executed, I get the Error: Typeconflict. (Exception of HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Is there a way, to read multivalue properties? Here is an example of the msip_labels property (GUIDs replaced with XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX):

msip_labels: MSIP_Label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_Enabled=true;
 MSIP_Label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_SetDate=2019-11-14T07:16:38Z;
 MSIP_Label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_Method=Privileged;
 MSIP_Label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_Name=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX;
 MSIP_Label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_SiteId=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX;
 MSIP_Label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_ActionId=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX;
 MSIP_Label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_ContentBits=1
msip_label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_enabled: true
msip_label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_setdate: 2019-11-14T07:16:48Z
msip_label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_method: Privileged
msip_label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_name:
 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
msip_label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_siteid:
 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
msip_label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_actionid:
 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
msip_label_XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX_contentbits: 0
c#
vsto
outlook-addin
azure-information-protection
asked on Stack Overflow Nov 14, 2019 by Franz Kiermaier

1 Answer

1

Finally I have figured out, how to create the property schema string, so it returns the right data type. Helpful for finding out the datatype was analyzing the item using Outlook Spy. The correct line of code with the right Schema String for querying msip_labels is:

var mSIPLabels = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/msip_labels/0x0000001F") as string;

after the property name, I had to pass the type descriptor 0x0000001F

answered on Stack Overflow Nov 14, 2019 by Franz Kiermaier

User contributions licensed under CC BY-SA 3.0