set azure information protection label for EWS

Gu, Wenlong A 65 Reputation points
2023-10-26T06:00:53.3633333+00:00

How can I set azure information protection label for sending email through EWS code?

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
525 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,465 questions
{count} votes

Accepted answer
  1. Jarvis Sun-MSFT 10,181 Reputation points Microsoft Vendor
    2023-11-01T08:40:38.5166667+00:00

    @Gu, Wenlong A,

    To set an Azure Information Protection label for sending email through EWS code, you can use the following steps:

    1. Create a new email message using the Microsoft.Exchange.WebServices.Data.EmailMessage class.
    2. Set the Microsoft.Exchange.WebServices.Data.EmailMessage.Sensitivity property to Microsoft.Exchange.WebServices.Data.Sensitivity.Normal.
    3. Set the Microsoft.Exchange.WebServices.Data.EmailMessage.Headers property to include the MSIP_Label_<GUID>_Enabled header, where <GUID> is the GUID of the label you want to apply.
    4. Send the email message using the Microsoft.Exchange.WebServices.Data.EmailMessage.SendAndSaveCopy() method.

    Here is an example code snippet that demonstrates how to set an Azure Information Protection label for sending email through EWS code in C#:

    EmailMessage message = new EmailMessage(service);
    message.Subject = "Test Email";
    message.Body = new MessageBody("This is a test email.");
    message.ToRecipients.Add("recipient@example.com");
    message.Sensitivity = Sensitivity.Normal;
    message.Headers.Add("MSIP_Label_12345678-1234-5678-1234-567812345678_Enabled", "true");
    message.SendAndSaveCopy();
    

    Please note that you will need to replace 12345678-1234-5678-1234-567812345678 with the GUID of the label you want to apply.


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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful