Office.SensitivityLabel interface  
Provides methods to get or set the sensitivity label of a message or appointment. For more information on sensitivity labels, see Learn about sensitivity labels.
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Compose
Important: To use the sensitivity label feature in your add-in, you must have a Microsoft 365 E5 subscription.
To learn more about how to manage sensitivity labels in your add-in, see Manage the sensitivity label of your message or appointment in compose mode.
Methods
| get | Gets the unique identifier (GUID) of the sensitivity label applied to a message or appointment being composed. | 
| get | Gets the unique identifier (GUID) of the sensitivity label applied to a message or appointment being composed. | 
| set | Applies the specified sensitivity label to the message or appointment being composed. | 
| set | Applies the specified sensitivity label to the message or appointment being composed. | 
Method Details
		getAsync(options, callback)
	 
	Gets the unique identifier (GUID) of the sensitivity label applied to a message or appointment being composed.
getAsync(options: Office.AsyncContextOptions, callback: (asyncResult: Office.AsyncResult<string>) => void): void;Parameters
- options
- Office.AsyncContextOptions
An object literal that contains one or more of the following properties:- asyncContext: Developers can provide any object they wish to access in the callback function.
- callback
- 
				(asyncResult: Office.AsyncResult<string>) => void 
When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object. The sensitivity label's GUID is returned in the asyncResult.value property.
Returns
void
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Compose
Important: To use the sensitivity label feature in your add-in, you must have a Microsoft 365 E5 subscription.
To learn more about how to manage sensitivity labels in your add-in, see Manage the sensitivity label of your message or appointment in compose mode.
		getAsync(callback)
	 
	Gets the unique identifier (GUID) of the sensitivity label applied to a message or appointment being composed.
getAsync(callback: (asyncResult: Office.AsyncResult<string>) => void): void;Parameters
- callback
- 
				(asyncResult: Office.AsyncResult<string>) => void 
When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object. The sensitivity label's GUID is returned in the asyncResult.value property.
Returns
void
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Compose
Important: To use the sensitivity label feature in your add-in, you must have a Microsoft 365 E5 subscription.
To learn more about how to manage sensitivity labels in your add-in, see Manage the sensitivity label of your message or appointment in compose mode.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml
// This snippet gets the current mail item's sensitivity label.
Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => {
  if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) {
    Office.context.mailbox.item.sensitivityLabel.getAsync((asyncResult) => {
      if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
        console.log(asyncResult.value);
      } else {
        console.log("Action failed with error: " + asyncResult.error.message);
      }
    });
  } else {
    console.log("Action failed with error: " + asyncResult.error.message);
  }
});
		setAsync(sensitivityLabel, options, callback)
	  
	Applies the specified sensitivity label to the message or appointment being composed.
setAsync(sensitivityLabel: string | SensitivityLabelDetails, options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;Parameters
- sensitivityLabel
- 
				string | Office.SensitivityLabelDetails 
The sensitivity label to be applied to the message or appointment being composed. The parameter value can be a sensitivity label's unique identifier (GUID) or a SensitivityLabelDetails object.
- options
- Office.AsyncContextOptions
An object literal that contains one or more of the following properties:- asyncContext: Developers can provide any object they wish to access in the callback function.
- callback
- 
				(asyncResult: Office.AsyncResult<void>) => void 
Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object.
Returns
void
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Compose
Important:
- To use the sensitivity label feature in your add-in, you must have a Microsoft 365 E5 subscription. 
- The - setAsyncmethod isn't supported on a message that's currently loaded using the- loadItemByIdAsyncmethod. For more information, see Activate your Outlook add-in on multiple messages.
Tip: To determine the sensitivity labels available for use, call the Office.context.sensitivityLabelsCatalog.getAsync method.
To learn more about how to manage sensitivity labels in your add-in, see Manage the sensitivity label of your message or appointment in compose mode.
		setAsync(sensitivityLabel, callback)
	  
	Applies the specified sensitivity label to the message or appointment being composed.
setAsync(sensitivityLabel: string | SensitivityLabelDetails, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;Parameters
- sensitivityLabel
- 
				string | Office.SensitivityLabelDetails 
The sensitivity label to be applied to the message or appointment being composed. The parameter value can be a sensitivity label's unique identifier (GUID) or a SensitivityLabelDetails object.
- callback
- 
				(asyncResult: Office.AsyncResult<void>) => void 
Optional. When the method completes, the function passed in the callback parameter is called with a single parameter, asyncResult, which is an Office.AsyncResult object.
Returns
void
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Compose
Important:
- To use the sensitivity label feature in your add-in, you must have a Microsoft 365 E5 subscription. 
- The - setAsyncmethod isn't supported on a message that's currently loaded using the- loadItemByIdAsyncmethod. For more information, see Activate your Outlook add-in on multiple messages.
Tip: To determine the sensitivity labels available for use, call the Office.context.sensitivityLabelsCatalog.getAsync method.
To learn more about how to manage sensitivity labels in your add-in, see Manage the sensitivity label of your message or appointment in compose mode.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/60-sensitivity-label/sensitivity-label.yaml
// This snippet sets the sensitivity label on the current mail item.
Office.context.sensitivityLabelsCatalog.getIsEnabledAsync((asyncResult) => {
  if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value == true) {
    Office.context.sensitivityLabelsCatalog.getAsync((asyncResult) => {
      if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
        const catalog = asyncResult.value;
        if (catalog.length > 0) {
          var id = catalog[0].id;
          Office.context.mailbox.item.sensitivityLabel.setAsync(id, (asyncResult) => {
            if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
              console.log(asyncResult.status);
            } else {
              console.log("Action failed with error: " + asyncResult.error.message);
            }
          });
        }
        else {
          console.log("Catalog list is empty");
        }
      } else {
        console.log("Action failed with error: " + asyncResult.error.message);
      }
    });
  } else {
    console.log("Action failed with error: " + asyncResult.error.message);
  }
});