I am drafting email in custom folder.
EmailMessage msg= new EmailMessage(service);
msg.setSubject("Hello world!");
msg.setBody(MessageBody.getMessageBodyFromText("Draft email using the EWS Java API."));
msg.getToRecipients().add("[email protected]");
// Tried to set extended property but not worked
ExtendedPropertyDefinition headerProperty = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.InternetHeaders,
"X-Classification",
MapiPropertyType.String);
msg.setExtendedProperty(headerProperty,"Provision X-header Internet message header");
msg.save(CUSTOM_FOLDER_ID);
I came to know that extended property will be helpful for classification/permission header. Ref link - https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-provision-x-headers-by-using-ews-in-exchange But how to set classification/permission ? X-Classification-Restricted something like this or any other way ?
I dont want to use setImportance / setSensitivity methods.
Manually we are setting in following way

Expectation from ews api to set classification/permission from code

How to set permission/classification(public/Restricted/Internal) to EmailMessage using ews java api?
Code snippet of working example appreciated. Thanks in advance
x-iccategory InternetHeaders is required to set classification/permission to email.
x-iccategory with value from [1-4] & supply value as string
Following are Values with classification/permission type of x-iccategory
1=Highly, 2=Restricted, 3=Internal, 4=Public
Following in sample code snippet
Classification/permission not applicable to email message from draft/custom folder
Note - Classification/Permission comes in picture when you trigger that email. Email goes to transport pipeline 1st and based on the value(Restricted/Public...) it gets applied