context (Mailbox requirement set 1.3)

Office.context

Office.context provides shared interfaces that are used by add-ins in all of the Office apps. This listing documents only those interfaces that are used by Outlook add-ins. For a full listing of the Office.context namespace, see the Office.context reference in the Common API.

Requirements
Requirement Value
Minimum mailbox requirement set version 1.1
Applicable Outlook mode Compose or Read

Properties

Property Modes Return type Minimum
requirement set
contentLanguage Compose
Read
String 1.1
displayLanguage Compose
Read
String 1.1
mailbox Compose
Read
Mailbox 1.1
requirements Compose
Read
RequirementSetSupport 1.1
roamingSettings Compose
Read
RoamingSettings 1.1
ui Compose
Read
UI 1.1

Property details

contentLanguage: String

Gets the locale (language) specified by the user for editing the item.

The contentLanguage value reflects the current Editing Language setting specified with File > Options > Language in the Office client application.

Type
  • String
Requirements
Requirement Value
Minimum mailbox requirement set version 1.1
Applicable Outlook mode Compose or Read
Example
function sayHelloWithContentLanguage() {
  const myContentLanguage = Office.context.contentLanguage;
  switch (myContentLanguage) {
    case 'en-US':
      write('Hello!');
      break;
    case 'en-NZ':
      write('G\'day mate!');
      break;
  }
}

// Function that writes to a div with id='message' on the page.
function write(message){
  document.getElementById('message').innerText += message;
}



displayLanguage: String

Gets the locale (language) in RFC 1766 Language tag format specified by the user for the UI of the Office client application.

The displayLanguage value reflects the current Display Language setting specified with File > Options > Language in the Office client application.

Type
  • String
Requirements
Requirement Value
Minimum mailbox requirement set version 1.1
Applicable Outlook mode Compose or Read
Example
function sayHelloWithDisplayLanguage() {
  const myDisplayLanguage = Office.context.displayLanguage;
  switch (myDisplayLanguage) {
    case 'en-US':
      write('Hello!');
      break;
    case 'en-NZ':
      write('G\'day mate!');
      break;
  }
}

// Function that writes to a div with id='message' on the page.
function write(message){
  document.getElementById('message').innerText += message;
}



requirements: RequirementSetSupport

Provides a method for determining what requirement sets are supported on the current application and platform.

Type
Requirements
Requirement Value
Minimum mailbox requirement set version 1.1
Applicable Outlook mode Compose or Read
Example
console.log(JSON.stringify(Office.context.requirements.isSetSupported("mailbox", "1.1")));



roamingSettings: RoamingSettings

Gets an object that represents the custom settings or state of a mail add-in saved to a user's mailbox.

The RoamingSettings object lets you store and access data for a mail add-in that is stored in a user's mailbox, so that is available to that add-in when it is running from any Outlook client used to access that mailbox.

Type
Requirements
Requirement Value
Minimum mailbox requirement set version 1.1
Minimum permission level restricted
Applicable Outlook mode Compose or Read



ui: UI

Provides objects and methods that you can use to create and manipulate UI components, such as dialog boxes, in your Office Add-ins.

Type
Requirements
Requirement Value
Minimum mailbox requirement set version 1.1
Applicable Outlook mode Compose or Read