Skip to content

Commit a5edb6b

Browse files
samantharamonlindalu-MSFTElizabethSamuel-MSFT
authored
[Outlook] (notifications) Create conceptual article (#5193)
* Create notifications article * Reformat table * Format columns * Fix InsightMessage description * Reword * Apply suggestions from review Co-authored-by: Linda Cannon <[email protected]> * Resize screenshot and apply suggestion from review * Fix images * Apply suggestions from review Co-authored-by: Elizabeth Samuel <[email protected]> * Update ms.date --------- Co-authored-by: Linda Cannon <[email protected]> Co-authored-by: Elizabeth Samuel <[email protected]>
1 parent cb58c3f commit a5edb6b

7 files changed

+279
-0
lines changed
1.62 KB
Loading
Loading
5.35 KB
Loading

docs/images/outlook-notification.png

6.67 KB
Loading
1.5 KB
Loading

docs/outlook/notifications.md

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
---
2+
title: Create notifications for your Outlook add-in
3+
description: Learn about the types of notification messages you can create for your Outlook add-in.
4+
ms.date: 05/29/2025
5+
ms.localizationpriority: medium
6+
---
7+
8+
# Create notifications for your Outlook add-in
9+
10+
Implement notification messages for your Outlook add-in to keep your users informed about important events, feedback, or errors with minimal disruption to their workflow.
11+
12+
> [!NOTE]
13+
> Support for the notifications API was introduced in Mailbox requirement set 1.3. Additional features were introduced in later requirement sets. To determine if your client supports these requirement sets, see [Outlook client support](/javascript/api/requirement-sets/outlook/outlook-api-requirement-sets#outlook-client-support).
14+
15+
## Supported Outlook surfaces and modes
16+
17+
Notification messages are supported on messages and appointments in both read and compose modes. They're displayed above the body of the mail item.
18+
19+
:::image type="content" source="../images/outlook-notification.png" alt-text="An insight notification displayed in an appointment in compose mode.":::
20+
21+
To manage a notification on a mail item, call [Office.context.mailbox.item.notificationMessages](/javascript/api/requirement-sets/outlook/requirement-set-1.3/office.context.mailbox.item#properties) in your add-in's JavaScript code. This property returns a [NotificationMessages](/javascript/api/outlook/office.notificationmessages) object with methods to add, remove, get, or replace notifications. The following code shows how to use these methods to manage your add-in's notifications.
22+
23+
```javascript
24+
const notificationMessages = Office.context.mailbox.item.notificationMessages;
25+
26+
// Sample informational message.
27+
const notificationDetails = {
28+
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
29+
message: "This is a sample notification message.",
30+
icon: "icon-16",
31+
persistent: false
32+
};
33+
34+
const notificationKey = "notification_01";
35+
36+
// Add a notification to the mail item.
37+
notificationMessages.addAsync(notificationKey, notificationDetails, (result) => {
38+
console.log("Added an informational notification.");
39+
});
40+
41+
// Get all the notifications of the mail item.
42+
notificationMessages.getAllAsync((result) => {
43+
console.log(JSON.stringify(result.value));
44+
});
45+
46+
// Replace a notification.
47+
const newNotification = {
48+
type: Office.MailboxEnums.ItemNotificationMessageType.ErrorMessage,
49+
message: "This is a sample error message."
50+
};
51+
52+
notificationMessages.replaceAsync(notificationKey, newNotification, (result) => {
53+
console.log("Replaced the existing notification.");
54+
});
55+
56+
// Remove a notification.
57+
notificationMessages.removeAsync(notificationKey, (result) => {
58+
console.log("Removed the notification.");
59+
});
60+
```
61+
62+
## Types of notifications
63+
64+
A notification consists of a unique identifier, an icon, and a message. Depending on the type, it could also include a **Dismiss** action or a custom action. There are different [types of notifications](/javascript/api/outlook/office.mailboxenums.itemnotificationmessagetype) you can display to the user to fit your particular scenario.
65+
66+
- [ErrorMessage](#errormessage)
67+
- [InformationalMessage](#informationalmessage)
68+
- [InsightMessage](#insightmessage)
69+
- [ProgressIndicator](#progressindicator)
70+
71+
The following sections describe each notification type, including its [properties](/javascript/api/outlook/office.notificationmessagedetails) and supported platforms.
72+
73+
### ErrorMessage
74+
75+
:::row:::
76+
:::column:::
77+
**Description**
78+
:::column-end:::
79+
:::column span="3":::
80+
Alerts the user about an error or failed operation. For example, use the `ErrorMessage` type to notify the user that their personalized signature wasn't successfully added to a message.
81+
82+
:::image type="content" source="../images/outlook-error-notification.png" alt-text="An error message notification.":::
83+
:::column-end:::
84+
:::row-end:::
85+
:::row:::
86+
:::column:::
87+
**Properties**
88+
:::column-end:::
89+
:::column span="3":::
90+
- Displays an error icon. This icon can't be customized.
91+
- Includes a **Dismiss** action to close the notification. If a user doesn't dismiss the error notification, it remains visible until the user sees it once before switching to another mail item.
92+
:::column-end:::
93+
:::row-end:::
94+
:::row:::
95+
:::column:::
96+
**Minimum supported requirement set**
97+
:::column-end:::
98+
:::column span="3":::
99+
[1.3](/javascript/api/requirement-sets/outlook/requirement-set-1.3/outlook-requirement-set-1.3)
100+
:::column-end:::
101+
:::row-end:::
102+
:::row:::
103+
:::column:::
104+
**Supported platforms**
105+
:::column-end:::
106+
:::column span="3":::
107+
- Web
108+
- Windows (new and classic)
109+
- Mac
110+
- Android
111+
- iOS
112+
:::column-end:::
113+
:::row-end:::
114+
115+
### InformationalMessage
116+
117+
:::row:::
118+
:::column:::
119+
**Description**
120+
:::column-end:::
121+
:::column span="3":::
122+
Provides information or feedback to the user. For example, use the `InformationalMessage` type to notify the user that their file upload completed successfully.
123+
124+
:::image type="content" source="../images/outlook-informational-notification.png" alt-text="An informational notification.":::
125+
:::column-end:::
126+
:::row-end:::
127+
:::row:::
128+
:::column:::
129+
**Properties**
130+
:::column-end:::
131+
:::column span="3":::
132+
- Must specify an icon. Although an icon is required, the custom icon is currently displayed only in classic Outlook on Windows. On other platforms, an information icon is shown.
133+
- Includes a **Dismiss** action to close the notification.
134+
- Can be customized to persist even after a user switches to another mail item. The notification remains until the add-in removes it or the user selects **Dismiss**.
135+
:::column-end:::
136+
:::row-end:::
137+
:::row:::
138+
:::column:::
139+
**Minimum supported requirement set**
140+
:::column-end:::
141+
:::column span="3":::
142+
[1.3](/javascript/api/requirement-sets/outlook/requirement-set-1.3/outlook-requirement-set-1.3)
143+
:::column-end:::
144+
:::row-end:::
145+
:::row:::
146+
:::column:::
147+
**Supported platforms**
148+
:::column-end:::
149+
:::column span="3":::
150+
- Web
151+
- Windows (new and classic)
152+
- Mac
153+
- Android
154+
- iOS
155+
:::column-end:::
156+
:::row-end:::
157+
158+
### InsightMessage
159+
160+
:::row:::
161+
:::column:::
162+
**Description**
163+
:::column-end:::
164+
:::column span="3":::
165+
Provides information or feedback to the user with an option to perform an action. For example, use the `InsightMessage` type to recommend adding catering services to a meeting with external recipients.
166+
167+
:::image type="content" source="../images/outlook-insight-notification.png" alt-text="An insight message notification.":::
168+
:::column-end:::
169+
:::row-end:::
170+
:::row:::
171+
:::column:::
172+
**Properties**
173+
:::column-end:::
174+
:::column span="3":::
175+
- Must specify an icon. Although an icon is required, the custom icon is displayed only in classic Outlook on Windows. On other platforms, an information icon is shown.
176+
- Includes an option to perform one [action](/javascript/api/outlook/office.notificationmessageaction). Currently, opening the add-in's task pane is the only supported action.
177+
- Includes a **Dismiss** action to close the notification.
178+
- Doesn't persist when a user switches to another mail item.
179+
:::column-end:::
180+
:::row-end:::
181+
:::row:::
182+
:::column:::
183+
**Minimum supported requirement set**
184+
:::column-end:::
185+
:::column span="3":::
186+
[1.10](/javascript/api/requirement-sets/outlook/requirement-set-1.10/outlook-requirement-set-1.10)
187+
:::column-end:::
188+
:::row-end:::
189+
:::row:::
190+
:::column:::
191+
**Supported platforms**
192+
:::column-end:::
193+
:::column span="3":::
194+
- Web
195+
- Windows (new and classic)
196+
- Mac
197+
:::column-end:::
198+
:::row-end:::
199+
200+
### ProgressIndicator
201+
202+
:::row:::
203+
:::column:::
204+
**Description**
205+
:::column-end:::
206+
:::column span="3":::
207+
Indicates the progress of an add-in operation. For example, use the `ProgressIndicator` to inform the user that their file is in the process of being attached to the mail item.
208+
209+
:::image type="content" source="../images/outlook-progress-notification.png" alt-text="A progress indicator notification.":::
210+
:::column-end:::
211+
:::row-end:::
212+
:::row:::
213+
:::column:::
214+
**Properties**
215+
:::column-end:::
216+
:::column span="3":::
217+
- In classic Outlook on Windows, displays a progress icon. On other platforms, displays an information icon. This icon can't be customized.
218+
- Doesn't persist when a user switches to another mail item.
219+
:::column-end:::
220+
:::row-end:::
221+
:::row:::
222+
:::column:::
223+
**Minimum supported requirement set**
224+
:::column-end:::
225+
:::column span="3":::
226+
[1.3](/javascript/api/requirement-sets/outlook/requirement-set-1.3/outlook-requirement-set-1.3)
227+
:::column-end:::
228+
:::row-end:::
229+
:::row:::
230+
:::column:::
231+
**Supported platforms**
232+
:::column-end:::
233+
:::column span="3":::
234+
- Web
235+
- Windows (new and classic)
236+
- Mac
237+
- Android
238+
- iOS
239+
:::column-end:::
240+
:::row-end:::
241+
242+
## Feature behaviors
243+
244+
When creating and managing notifications for your add-in, be mindful of the following behaviors, limitations, and best practices.
245+
246+
### Maximum number of notifications per mail item
247+
248+
In Outlook on the web, on Windows (new and classic), and on Mac, you can add a maximum of five notifications per message. In Outlook on mobile devices, only one notification can be added to a message. Setting an additional notification replaces the existing one.
249+
250+
### InsightMessage limitations
251+
252+
Only one `InsightMessage` notification is allowed per add-in on a mail item. In Outlook on the web and new Outlook on Windows, the `InsightMessage` type is only supported in compose mode.
253+
254+
### Notification icons and unified manifest for Microsoft 365
255+
256+
If your add-in uses the [unified manifest for Microsoft 365](../develop/unified-manifest-overview.md), you can't customize the icon of an `InformationalMessage` or `InsightMessage` notification. The notification uses the first image specified in the ["icons"](/microsoft-365/extensibility/schema/extension-common-custom-group-controls-item#icons) array of the first [extensions.ribbons.tabs.groups.controls](/microsoft-365/extensibility/schema/extension-common-custom-group-controls-item) object of the manifest. Although this is the case, you must still specify a string in the [icon](/javascript/api/outlook/office.notificationmessagedetails#outlook-office-notificationmessagedetails-icon-member) property of your [NotificationMessageDetails](/javascript/api/outlook/office.notificationmessagedetails) object (for example, "icon-16").
257+
258+
### Notification icons in Outlook on mobile devices
259+
260+
In compose mode, while the style of each notification type varies on other Outlook clients, notifications in Outlook on Android and on iOS all use the same style. The notification message always uses an information icon.
261+
262+
### Notifications for multiple selected messages
263+
264+
When managing notifications for multiple selected messages, only the `getAllAsync` method is supported. To learn more, see [Activate your Outlook add-in on multiple messages](item-multi-select.md).
265+
266+
### Best practices for ProgressIndicator notifications
267+
268+
When implementing a `ProgressIndicator` notification in your add-in, once the applicable operation or action completes, replace the progress notification with another notification type. This is a best practice to ensure that your users always get the latest status of an operation.
269+
270+
## Try the code example in Script Lab
271+
272+
Learn how you can use notifications in your add-in by trying out the [Work with notification messages](https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/35-notifications/add-getall-remove.yaml) sample in [Script Lab for Outlook](https://appsource.microsoft.com/product/office/wa200001603). For more information on Script Lab, see [Explore Office JavaScript API using Script Lab](../overview/explore-with-script-lab.md).
273+
274+
## See also
275+
276+
- [Use the Office dialog API in Office Add-ins](../develop/dialog-api-in-office-add-ins.md)
277+
- [Configure your Outlook add-in for event-based activation](autolaunch.md)

docs/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ items:
814814
href: outlook/use-rest-api.md
815815
- name: Call Exchange web services
816816
href: outlook/web-services.md
817+
- name: Manage notifications
818+
href: outlook/notifications.md
817819
- name: Get or set categories
818820
href: outlook/categories.md
819821
- name: Get or set internet headers

0 commit comments

Comments
 (0)