Office.NotificationMessages interface

The NotificationMessages object is returned as the notificationMessages property of an item.

[ API set: Mailbox 1.3 ]

Remarks

Minimum permission levelReadItem
Applicable Outlook modeCompose or read

Methods

addAsync(key, JSONmessage, options, callback)

Adds a notification to an item.

There are a maximum of 5 notifications per message. Setting more will return a NumberOfNotificationMessagesExceeded error.

getAllAsync(options, callback)

Returns all keys and messages for an item.

[ API set: Mailbox 1.3 ]

removeAsync(key, options, callback)

Removes a notification message for an item.

[ API set: Mailbox 1.3 ]

replaceAsync(key, JSONmessage, options, callback)

Replaces a notification message that has a given key with another message.

If a notification message with the specified key doesn't exist, replaceAsync will add the notification.

[ API set: Mailbox 1.3 ]

Method Details

addAsync(key, JSONmessage, options, callback)

Adds a notification to an item.

There are a maximum of 5 notifications per message. Setting more will return a NumberOfNotificationMessagesExceeded error.

addAsync(key: string, JSONmessage: NotificationMessageDetails, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<void>) => void): void;
Parameters
key
string

A developer-specified key used to reference this notification message. Developers can use it to modify this message later. It can't be longer than 32 characters.

JSONmessage
NotificationMessageDetails

A JSON object that contains the notification message to be added to the item. It contains a NotificationMessageDetails object.

options
Office.AsyncContextOptions

Optional. 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 method.

callback
(result: AsyncResult<void>) => void

Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. [Api set: Mailbox 1.3]

Returns
void
Remarks
Minimum permission levelReadItem
Applicable Outlook modeCompose or read

In addition to this signature, the method also has the following signatures:

addAsync(key: string, JSONmessage: NotificationMessageDetails): void;

addAsync(key: string, JSONmessage: NotificationMessageDetails, options: Office.AsyncContextOptions): void;

addAsync(key: string, JSONmessage: NotificationMessageDetails, callback: (result: AsyncResult<void>) => void): void;

Examples

// Create three notifications, each with a different key
Office.context.mailbox.item.notificationMessages.addAsync("progress", {
    type: "progressIndicator",
    message : "An add-in is processing this message."
});
Office.context.mailbox.item.notificationMessages.addAsync("information", {
    type: "informationalMessage",
    message : "The add-in processed this message.",
    icon : "iconid",
    persistent: false
});
Office.context.mailbox.item.notificationMessages.addAsync("error", {
    type: "errorMessage",
    message : "The add-in failed to process this message."
});

getAllAsync(options, callback)

Returns all keys and messages for an item.

[ API set: Mailbox 1.3 ]

getAllAsync(options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<Office.NotificationMessageDetails[]>) => void): void;
Parameters
options
Office.AsyncContextOptions

Optional. 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 method.

callback
(result: AsyncResult<Office.NotificationMessageDetails>) => void[]

Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult. The value property of the result is an array of NotificationMessageDetails objects.

Returns
void
Remarks
Minimum permission levelReadItem
Applicable Outlook modeCompose or read

In addition to the main signature, this method also has this signature:

getAllAsync(callback: (result: AsyncResult&lt;Office.NotificationMessageDetails[]&gt;) => void): void;

Examples

// Get all notifications
Office.context.mailbox.item.notificationMessages.getAllAsync(function (asyncResult) {
    if (asyncResult.status != "failed") {
        Office.context.mailbox.item.notificationMessages.replaceAsync( "notifications", {
            type: "informationalMessage",
            message : "Found " + asyncResult.value.length + " notifications.",
            icon : "iconid",
            persistent: false
        });
    }
});

removeAsync(key, options, callback)

Removes a notification message for an item.

[ API set: Mailbox 1.3 ]

removeAsync(key: string, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<void>) => void): void;
Parameters
key
string

The key for the notification message to remove.

options
Office.AsyncContextOptions

Optional. 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 method.

callback
(result: AsyncResult<void>) => void

Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult.

Returns
void
Remarks
Minimum permission levelReadItem
Applicable Outlook modeCompose or read

In addition to the main signature, this method also has these signatures:

removeAsync(key: string): void;

removeAsync(key: string, options: Office.AsyncContextOptions): void;

removeAsync(key: string, callback: (result: AsyncResult<void>) => void): void;

Examples

// Remove a notification
Office.context.mailbox.item.notificationMessages.removeAsync("progress");

replaceAsync(key, JSONmessage, options, callback)

Replaces a notification message that has a given key with another message.

If a notification message with the specified key doesn't exist, replaceAsync will add the notification.

[ API set: Mailbox 1.3 ]

replaceAsync(key: string, JSONmessage: NotificationMessageDetails, options?: Office.AsyncContextOptions, callback?: (result: AsyncResult<void>) => void): void;
Parameters
key
string

The key for the notification message to replace. It can't be longer than 32 characters.

JSONmessage
NotificationMessageDetails

A JSON object that contains the new notification message to replace the existing message. It contains a NotificationMessageDetails object.

options
Office.AsyncContextOptions

Optional. 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 method.

callback
(result: AsyncResult<void>) => void

Optional. When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult.

Returns
void
Remarks
Minimum permission levelReadItem
Applicable Outlook modeCompose or read

In addition to the main signature, this method also has these signatures:

replaceAsync(key: string, JSONmessage: NotificationMessageDetails): void;

replaceAsync(key: string, JSONmessage: NotificationMessageDetails, options: Office.AsyncContextOptions): void;

replaceAsync(key: string, JSONmessage: NotificationMessageDetails, callback: (result: AsyncResult<void>) => void): void;

Examples

// Replace a notification with an informational notification
Office.context.mailbox.item.notificationMessages.replaceAsync("progress", {
    type: "informationalMessage",
    message : "The message was processed successfully.",
    icon : "iconid",
    persistent: false
});