Office.NotificationMessageAction interface

The definition of the action for a notification message.

Remarks

[ API set: Mailbox 1.10 ]

Minimum permission level: read item

Applicable Outlook mode: Compose or Read

Important: In modern Outlook on the web, the NotificationMessageAction object is available in Compose mode only.

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml

// Adds an informational message with actions to the mail item.
const id = $("#notificationId").val().toString();

const itemId = Office.context.mailbox.item.itemId;
const details = {
  type: Office.MailboxEnums.ItemNotificationMessageType.InsightMessage,
  message: "This is an insight notification with id = " + id,
  icon: "icon1",
  actions: [
    {
      actionText: "Open insight",
      actionType: Office.MailboxEnums.ActionType.ShowTaskPane,
      // Identify whether the current mail item is in read or compose mode to set the appropriate commandId value.
      commandId: (itemId == undefined ? "PG.HelpCommand.Compose" : "PG.HelpCommand.Read"),
      contextData: { a: "aValue", b: "bValue" }
    }
  ]
};

Office.context.mailbox.item.notificationMessages.addAsync(id, details, handleResult);

Properties

actionText

The text of the action link.

actionType

The type of action to be performed. ActionType.ShowTaskPane is the only supported action.

commandId

The button defined in the manifest.

contextData

Any JSON data the action button needs to pass on to the add-in.

Property Details

actionText

The text of the action link.

actionText: string;

Property Value

string

actionType

The type of action to be performed. ActionType.ShowTaskPane is the only supported action.

actionType: string | MailboxEnums.ActionType;

Property Value

commandId

The button defined in the manifest.

commandId: string;

Property Value

string

contextData

Any JSON data the action button needs to pass on to the add-in.

contextData: any;

Property Value

any

Remarks

Important:

  • In Outlook on Windows, the any type is supported starting in Version 2402 (Build 17308.20000). In earlier versions of Outlook on Windows, only the string type is supported.

  • To retrieve the JSON data, call Office.context.mailboxitem.getInitializationContextAsync. If you create a JSON string using JSON.stringify() and assign it to the contextData property, you must parse the string using JSON.parse() once you retrieve it.