Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Outlook] (Smart Alerts) Document Markdown support #4417

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added docs/images/outlook-smart-alerts-bold.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/outlook-smart-alerts-custom-button.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/outlook-smart-alerts-link.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/outlook-smart-alerts-list.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/outlook-smart-alerts-new-line.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/outlook-smart-alerts-send-mode-override.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/outlook-win-smart-alert.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 62 additions & 2 deletions docs/outlook/onmessagesend-onappointmentsend-events.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Handle OnMessageSend and OnAppointmentSend events in your Outlook add-in with Smart Alerts
description: Learn about the Smart Alerts implementation and how it handles the OnMessageSend and OnAppointmentSend events in your event-based Outlook add-in.
ms.date: 03/12/2024
ms.date: 03/26/2024
ms.topic: concept-article
ms.localizationpriority: medium
---
Expand Down Expand Up @@ -215,7 +215,7 @@ In addition to these constraints, only one instance each of the `OnMessageSend`
While you can change the Smart Alerts dialog message and **Don't Send** button to suit your add-in scenario, the following can't be customized.

- The dialog's title bar. Your add-in's name is always displayed there.
- The message's format. For example, you can't change the text's font size and color or insert a bulleted list.
- The font or color of the dialog message. However, you can use Markdown to format certain elements of your message. For a list of supported elements, see [Limitations to formatting the dialog message using Markdown](#limitations-to-formatting-the-dialog-message-using-markdown).
- Dialogs that provide information on event processing and progress. For example, the text and options that appear in the timeout and long-running operation dialogs can't be changed.

If you customize the **Don't Send** button in the dialog, you can only assign a task pane command to it. Function commands aren't supported. If you select a **Don't Send** button with an assigned function command, the command is ignored and the add-in cancels the send operation and closes the dialog. When this occurs, no error is shown or logged. For guidance on the types of add-in commands, see [Types of add-in commands](../design/add-in-commands.md#types-of-add-in-commands).
Expand All @@ -225,6 +225,66 @@ In Outlook on the web and in new Outlook on Windows (preview):
- The `OnAppointmentSend` event only occurs when the meeting being sent was created through the **New Event** option. If the meeting being sent was created by selecting a date and time directly from the calendar, the `OnAppointmentSend` event doesn't occur.
- When forwarding a meeting, the `OnAppointmentSend` event only occurs if the organizer forwards the meeting. It doesn't occur if an attendee forwards the meeting to which they're invited.

### Limitations to formatting the dialog message using Markdown

> [!NOTE]
> Support for Markdown in a Smart Alerts dialog is currently in preview in Outlook on Windows only. Features in preview shouldn't be used in production add-ins. We invite you to try out this feature in test or development environments and welcome feedback on your experience through GitHub (see the Feedback section at the end of this page).
>
> To test this feature in Outlook on Windows, you must install Version 2403 (Build 17330.10000) or later. Then, join the [Microsoft 365 Insider program](https://insider.microsoft365.com/join/windows) and select the **Beta Channel** option in your Outlook client to access Office beta builds.

You can use Markdown to format the message of a Smart Alerts dialog. However, only the following elements are supported.

- Bold, italic, or bold and italic text. Both the [asterisk (*) and underscore (_) formats](https://www.markdownguide.org/basic-syntax/#emphasis) are supported.

```javascript
event.completed({
allowEvent: false,
...
errorMessageMarkdown: "**Important**: Apply the appropriate sensitivity label to your message before sending."
});
```

:::image type="content" source="../images/outlook-smart-alerts-bold.png" alt-text="A sample Smart Alerts dialog with bold text.":::

- Unordered or bulleted lists. To create an item in the list, begin with a dash (`-`) or asterisk (`*`), add the content, then append `\r` to signify item completion.
samantharamon marked this conversation as resolved.
Show resolved Hide resolved

```javascript
event.completed({
allowEvent: false,
...
errorMessageMarkdown: "Your email doesn't meet company guidelines.\n\nFor additional assistance, contact the IT Service Desk:\n\n- Phone number: 425-555-0102\r- Email: it@contoso.com\r- Website: [Contoso IT Service Desk](https://www.contoso.com/it-service-desk)\r"
});
```

:::image type="content" source="../images/outlook-smart-alerts-list.png" alt-text="A sample Smart Alerts dialog containing a bulleted list.":::

- Links. To create a link, enclose your link text in square brackets (`[]`), then enclose the URL in parentheses (`()`). The angle brackets format (`<>`) isn't supported.

```javascript
event.completed({
allowEvent: false,
...
errorMessageMarkdown: "Need onsite assistance on the day of your meeting? Visit the [Contoso Facilities](https://www.contoso.com/facilities/meetings) page to learn more."
});
```

:::image type="content" source="../images/outlook-smart-alerts-link.png" alt-text="A sample Smart Alerts dialog containing a link.":::

- New lines. Use `\n\n` to create a new line.

```javascript
event.completed({
allowEvent: false,
...
errorMessageMarkdown: "Add a personalized user avatar to your signature today!\n\nTo customize your signature, visit [Customize my email signature](https://www.fabrikam.com/marketing/customize-email-signature)."
});
```

:::image type="content" source="../images/outlook-smart-alerts-new-line.png" alt-text="A sample Smart Alerts dialog containing a new line in the message.":::

> [!TIP]
> To escape characters in your message, such as an asterisk, add a backslash (`\`) before the character.

## Best practices

The Smart Alerts feature ensures that all outgoing mail items are compliant with the information protection policies of an organization and helps users improve their messages through recommendations. To ensure your add-in always provides users with a smooth and efficient sending experience, observe the following guidelines.
Expand Down
63 changes: 57 additions & 6 deletions docs/outlook/smart-alerts-onmessagesend-walkthrough.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Automatically check for an attachment before a message is sent
description: Learn how to implement an event-based add-in that implements Smart Alerts to automatically check a message for an attachment before it's sent.
ms.date: 02/29/2024
ms.date: 03/26/2024
ms.topic: how-to
ms.localizationpriority: medium
---
Expand Down Expand Up @@ -223,7 +223,7 @@ To configure the manifest, select the tab for the type of manifest you are using

You have to implement handling for your selected event.

In this scenario, you'll add handling for sending a message. Your add-in will check for certain keywords in the message. If any of those keywords are found, it will then check if there are any attachments. If there are no attachments, your add-in will recommend to the user to add the possibly missing attachment.
In this scenario, you'll add handling for sending a message. Your add-in will check for certain keywords in the message. If any of those keywords are found, it will then check for any attachments. If there are no attachments, your add-in will recommend to the user to add the possibly missing attachment.

1. From the same quick start project, create a new folder named **launchevent** under the **./src** directory.

Expand Down Expand Up @@ -296,12 +296,29 @@ In this scenario, you'll add handling for sending a message. Your add-in will ch

event.completed({
allowEvent: false,
errorMessage: "Looks like the body of your message includes an image or an inline file. Attach a copy to the message before sending."
errorMessage: `
Looks like the body of your message includes an image or an inline file.
Attach a copy to the message before sending.`,
// TIP: In addition to the formatted message, it's recommended to also set a
// plain text message in the errorMessage property for compatibility on
// older versions of Outlook clients.
errorMessageMarkdown: `
Looks like the body of your message includes an image or an inline file.
Attach a copy to the message before sending.\n\n
**Tip**: For guidance on how to attach a file, see
[Attach files in Outlook](https://support.microsoft.com/office/48b8dca1-7a76-43ce-97d1-e1cf73893f55).`
});
} else {
event.completed({
allowEvent: false,
errorMessage: "Looks like you're forgetting to include an attachment."
errorMessage: "Looks like you're forgetting to include an attachment.",
// TIP: In addition to the formatted message, it's recommended to also set a
// plain text message in the errorMessage property for compatibility on
// older versions of Outlook clients.
errorMessageMarkdown: `
Looks like you're forgetting to include an attachment.\n\n
**Tip**: For guidance on how to attach a file, see
[Attach files in Outlook](https://support.microsoft.com/office/48b8dca1-7a76-43ce-97d1-e1cf73893f55).`
});
}
}
Expand Down Expand Up @@ -356,14 +373,31 @@ To modify the text of the **Don't Send** button or assign it a task pane command

event.completed({
allowEvent: false,
errorMessage: "Looks like the body of your message includes an image or an inline file. Attach a copy to the message before sending.",
errorMessage: `
Looks like the body of your message includes an image or an inline file.
Attach a copy to the message before sending.`,
// TIP: In addition to the formatted message, it's recommended to also set a
// plain text message in the errorMessage property for compatibility on
// older versions of Outlook clients.
errorMessageMarkdown: `
Looks like the body of your message includes an image or an inline file.
Attach a copy to the message before sending.\n\n
**Tip**: For guidance on how to attach a file, see
[Attach files in Outlook](https://support.microsoft.com/office/48b8dca1-7a76-43ce-97d1-e1cf73893f55).`,
cancelLabel: "Add an attachment",
commandId: "msgComposeOpenPaneButton"
});
} else {
event.completed({
allowEvent: false,
errorMessage: "Looks like you're forgetting to include an attachment.",
// TIP: In addition to the formatted message, it's recommended to also set a
// plain text message in the errorMessage property for compatibility on
// older versions of Outlook clients.
errorMessageMarkdown: `
Looks like you're forgetting to include an attachment.\n\n
**Tip**: For guidance on how to attach a file, see
[Attach files in Outlook](https://support.microsoft.com/office/48b8dca1-7a76-43ce-97d1-e1cf73893f55).`,
cancelLabel: "Add an attachment",
commandId: "msgComposeOpenPaneButton"
});
Expand Down Expand Up @@ -400,7 +434,17 @@ To override the send mode option at runtime, you must set the [sendModeOverride]

event.completed({
allowEvent: false,
errorMessage: "Looks like the body of your message includes an image or an inline file. Would you like to attach a copy of it to the message?",
errorMessage: `
Looks like the body of your message includes an image or an inline file.
Would you like to attach a copy of it to the message?`,
// TIP: In addition to the formatted message, it's recommended to also set a
// plain text message in the errorMessage property for compatibility on
// older versions of Outlook clients.
errorMessageMarkdown: `
Looks like the body of your message includes an image or an inline file.
Would you like to attach a copy of it to the message?\n\n
**Tip**: For guidance on how to attach a file, see
[Attach files in Outlook](https://support.microsoft.com/office/48b8dca1-7a76-43ce-97d1-e1cf73893f55).`,
cancelLabel: "Attach a copy",
commandId: "msgComposeOpenPaneButton",
sendModeOverride: Office.MailboxEnums.SendModeOverride.PromptUser
Expand All @@ -409,6 +453,13 @@ To override the send mode option at runtime, you must set the [sendModeOverride]
event.completed({
allowEvent: false,
errorMessage: "Looks like you're forgetting to include an attachment.",
// TIP: In addition to the formatted message, it's recommended to also set a
// plain text message in the errorMessage property for compatibility on
// older versions of Outlook clients.
errorMessageMarkdown: `
Looks like you're forgetting to include an attachment.\n\n
**Tip**: For guidance on how to attach a file, see
[Attach files in Outlook](https://support.microsoft.com/office/48b8dca1-7a76-43ce-97d1-e1cf73893f55).`,
cancelLabel: "Add an attachment",
commandId: "msgComposeOpenPaneButton"
});
Expand Down