Office.NotificationMessageAction interface
The definition of the action for a notification message.
Remarks
Minimum permission level: read item
Applicable Outlook mode: Compose or Read
Important: In modern Outlook on the web and new Outlook on Windows, 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
action |
The text of the action link. |
action |
The type of action to be performed. |
command |
The button defined in the manifest. |
context |
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
string | Office.MailboxEnums.ActionType
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 thestring
type is supported.To retrieve the JSON data, call
Office.context.mailboxitem.getInitializationContextAsync
. If you create a JSON string usingJSON.stringify()
and assign it to thecontextData
property, you must parse the string usingJSON.parse()
once you retrieve it.
Office Add-ins