Set sensitivity label on mail message using graph api

ECIT DEV 36 Reputation points
2022-01-03T04:30:21.52+00:00

Was going through the Mail Graph API but couldnt find of any way to set the sensitivity(Private/Public/Confidential etc) on the mail message. Could you please let us know if this is feasible or not.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Answer accepted by question author
  1. Glen Scales 4,446 Reputation points
    2022-01-05T01:40:33.147+00:00

    You can set it using the singleValueExtendedProperty for the PidTagSensitivity property https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagsensitivity-canonical-property eg the following sets it to personal on an email

    {  
        "message": {  
            "subject": "Meet for lunch?",  
            "body": {  
                "contentType": "Text",  
                "content": "The new cafeteria is open."  
            },  
            "toRecipients": [  
                {  
                    "emailAddress": {  
                        "address": "******@domain.com"  
                    }  
                }  
            ],  
            "singleValueExtendedProperties": [  
                {  
                    "id": "Integer 0x0036",  
                    "value": "1"  
                }  
            ]  
        }  
    }  
    
    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Matt 0 Reputation points
    2025-12-05T12:23:24.3833333+00:00

    Hi,

    It is possible to set Microsoft Information Protection sensitivity labels by appending a singleValueExtendedProperties block, although in a slightly different way that Glen mentions above. You'll need:

    • Entra tenant ID
    • The human-readable name of your sensitivity label
    • The GUID associated with that label. This can be obtained from the M365 admin interface or using a browser's dev tools to view the response from PolicyHandler.ashx?action=getpolicylabels when assigning a label to a Word document, for example

    This is the updated request body...

    {
    "message": {
        "subject": "Meet for lunch?",
        "body": {
            "contentType": "Text",
            "content": "The new cafeteria is open."
        },
        "toRecipients": [
            {
                "emailAddress": {
                    "address": "******@domain.com"
                }
            }
        ],
        "singleValueExtendedProperties": [  
            {
                "id":  "String {00020386-0000-0000-C000-000000000046} Name msip_labels",
                "value": "MSIP_Label_<SENSITIVITY_LABEL_GUID>_Enabled=True;MSIP_Label_<SENSITIVITY_LABEL_GUID>_SiteId=<ENTRA_TENANT_ID>;MSIP_Label_<SENSITIVITY_LABEL_GUID>_SetDate=<ISO_8601_TIMESTAMP>;MSIP_Label_<SENSITIVITY_LABEL_GUID>_Name=<SENSITIVITY_LABEL_NAME>;MSIP_Label_<SENSITIVITY_LABEL_GUID>_ContentBits=1;MSIP_Label_<SENSITIVITY_LABEL_GUID>_Method=Privileged;"
            }
        ]
    }
    
    

    This is a Powershell representation of the message object, where it's perhaps easier to read the singleValueExtendedProperties details:

    $timeStamp = (Get-Date -Format "yyyy-MM-ddTHH:mm:ss.fffZ")
    $tenantId = "11111111-1111-1111-1111-111111111111"
    $label = @{
        name = "Confidential"
        guid = "22222222-2222-2222-2222-222222222222"
    }
    $emailPayload = @{
        message = @{
            subject = "Meet for lunch?"
            body = @{
                contentType = "Text"
                content = "The new cafeteria is open."
            }
            toRecipients = @(
                @{
                    emailAddress = @{
                        address = "******@domain.com"
                    }
                }
            )
            singleValueExtendedProperties = @(
                @{
                    id = "String {00020386-0000-0000-C000-000000000046} Name msip_labels"
                    value = "MSIP_Label_$($label.guid)_Enabled=True;`
                        MSIP_Label_$($label.guid)_SiteId=$($tenantId);`
                        MSIP_Label_$($label.guid)_SetDate=$($timeStamp);`
                        MSIP_Label_$($label.guid)_Name=$($label.name);`
                        MSIP_Label_$($label.guid)_ContentBits=1;`
                        MSIP_Label_$($label.guid)_Method=Privileged;"
                }
            )
        }
    }
    

    Hope that's useful.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.