Set sensitivity label on mail message using graph api

ECIT DEV 26 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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,298 questions
0 comments No comments
{count} votes

Accepted answer
  1. Glen Scales 4,431 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": "gscales@domain.com"  
                    }  
                }  
            ],  
            "singleValueExtendedProperties": [  
                {  
                    "id": "Integer 0x0036",  
                    "value": "1"  
                }  
            ]  
        }  
    }  
    
    1 person found this answer helpful.

4 additional answers

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,681 Reputation points Microsoft Vendor
    2022-01-04T13:25:13.39+00:00

    Hi @ECIT DEV ,

    Currently message sensitivity property(Public, Private, Confidential etc.) can not be set via the Graph API queries. As per documentation only these message properties can be set using Graph API.

    You can submit this feature request using this support link, which will be monitored by Microsoft team and make the enhancements to Graph API.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

    0 comments No comments

  2. ECIT DEV 26 Reputation points
    2022-01-06T01:39:18.937+00:00

    @Glen Scales - Thank you for the response. I was able to set sensitivity label using extended properties.
    var singleValueLegacyExtendedProperty = new SingleValueLegacyExtendedProperty
    {
    Id = "Integer 0x0036",
    Value = "3"
    };
    mailmessage.SingleValueExtendedProperties = new MessageSingleValueExtendedPropertiesCollectionPage();
    mailmessage.SingleValueExtendedProperties.Add(singleValueLegacyExtendedProperty);

    Also is there any way i can also set DoNotForward property on mail message.

    Thank you

    0 comments No comments

  3. Glen Scales 4,431 Reputation points
    2022-01-07T00:12:50.52+00:00

    No do not forward is part of the RMS/AIP https://learn.microsoft.com/en-us/azure/information-protection/configure-usage-rights#do-not-forward-option-for-emails which the graph doesn't support at the moment. You can disable the Forward Verb (and reply verbs (eg https://stackoverflow.com/questions/68667907/send-exchange-email-with-voting-buttons-using-ms-exchange-graph-api-java-sdk/68668010#68668010) which Outlook supports but this isn't the same as the encryption that AIP does.

    0 comments No comments

  4. Solar, Jason 1 Reputation point
    2022-09-29T14:01:32.75+00:00

    Are you saying that can use ID's vs guids for this method - "https://<foo_domain>.sharepoint.com/_api/v2.1/drives/<driveID>/items/<docID>/setsensitivityLabel

    0 comments No comments