Office.DisplayedSubject interface

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Provides a method to temporarily set the content displayed in the subject of a message in read mode.

Remarks

[ API set: Mailbox preview ]

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

Methods

setAsync(data, options, callback)

Temporarily sets the content displayed in the subject of a message in read mode. The set content will remain visible until the user switches to a different message or closes the window of the current message.

setAsync(data, callback)

Temporarily sets the content displayed in the subject of a message in read mode. The set content will remain visible until the user switches to a different message or closes the window of the current message.

Method Details

setAsync(data, options, callback)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Temporarily sets the content displayed in the subject of a message in read mode. The set content will remain visible until the user switches to a different message or closes the window of the current message.

setAsync(data: string, options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

Parameters

data

string

The string to be temporarily displayed in the subject of a message. The string is limited to 255 characters.

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. Any errors encountered will be provided in the asyncResult.error property.

Returns

void

Remarks

[ API set: Mailbox preview ]

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

Important:

  • If multiple add-ins that implement setAsync run simultaneously, the content set by the last add-in that completes the setAsync operation is displayed in the subject field.

  • The content set by the setAsync method is only displayed while the user is viewing the item. It isn't cached in Outlook and doesn't sync with other Outlook clients.

  • If you save a message after calling setAsync, the original subject appears in the saved item.

  • The setAsync method isn't supported on multiple selected messages.

setAsync(data, callback)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Temporarily sets the content displayed in the subject of a message in read mode. The set content will remain visible until the user switches to a different message or closes the window of the current message.

setAsync(data: string, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

Parameters

data

string

The string to be temporarily displayed in the subject of a message. The string is limited to 255 characters.

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. Any errors encountered will be provided in the asyncResult.error property.

Returns

void

Remarks

[ API set: Mailbox preview ]

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

Important:

  • If multiple add-ins that implement setAsync run simultaneously, the content set by the last add-in that completes the setAsync operation is displayed in the subject field.

  • The content set by the setAsync method is only displayed while the user is viewing the item. It isn't cached in Outlook and doesn't sync with other Outlook clients.

  • If you save a message after calling setAsync, the original subject appears in the saved item.

  • The setAsync method isn't supported on multiple selected messages.

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/99-preview-apis/set-displayed-body-subject.yaml

// This snippet temporarily sets the content displayed in the subject field of a message in read mode.
// The set content will remain visible until the user switches to a different message in the Reading Pane or closes the window of the current message.
const subjectText = $("#subject-text-field")
  .val()
  .toString();
Office.context.mailbox.item.display.subject.setAsync(subjectText, (asyncResult) => {
  if (asyncResult.status === Office.AsyncResultStatus.Failed) {
    console.log(`Action failed with error: ${asyncResult.error.message}`);
    return;
  }

  console.log("Temporarily set the content displayed in the subject field.");
});