Office.SmartAlertsEventCompletedOptions interface

Specifies the behavior of a Smart Alerts add-in when it completes processing an OnMessageSend or OnAppointmentSend event.

Remarks

[ API set: Mailbox 1.12 ]

Minimum permission level (Outlook): restricted

Applicable Outlook mode: Compose

Examples

// The following example checks whether a location is specified in an appointment before it's sent.
function onAppointmentSendHandler(event) {
    Office.context.mailbox.item.location.getAsync({ asyncContext: event }, asyncResult => {
        const event = asyncResult.asyncContext;
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.log(asyncResult.error.message);
            // If the add-in is unable to retrieve the appointment's location, the appointment isn't sent.
            event.completed({ allowEvent: false, errorMessage: "Failed to get the appointment's location." });
            return;
        }

        if (asyncResult.value === "") {
            // If no location is specified, the appointment isn't sent and the user is alerted to include a location.
            event.completed(
                {
                    allowEvent: false,
                    cancelLabel: "Add a location",
                    commandId: "msgComposeOpenPaneButton",
                    contextData: JSON.stringify({ a: "aValue", b: "bValue" }),
                    errorMessage: "Don't forget to add a meeting location.",
                    errorMessageMarkdown: `
                        Don't forget to add a meeting location.\n\n
                        **Tip**: For a list of locations,
                        see [Meeting Locations]("https://www.contoso.com/meeting-locations).`,
                    sendModeOverride: Office.MailboxEnums.SendModeOverride.PromptUser
                }
            );
        } else {
            // If a location is specified, the appointment is sent.
            event.completed({ allowEvent: true });
        }
    });
}

Properties

allowEvent

When you use the completed method to signal completion of an event handler, this value indicates if the handled event should continue execution or be canceled. For example, an add-in that handles the OnMessageSend or OnAppointmentSend event can set allowEvent to false to cancel the sending of an item. For a complete sample, see the Smart Alerts walkthrough.

errorMessage

When you use the completed method to signal completion of an event handler and set its allowEvent property to false, this property sets the error message that will be displayed to the user. For an example, see the Smart Alerts walkthrough.

Property Details

allowEvent

When you use the completed method to signal completion of an event handler, this value indicates if the handled event should continue execution or be canceled. For example, an add-in that handles the OnMessageSend or OnAppointmentSend event can set allowEvent to false to cancel the sending of an item. For a complete sample, see the Smart Alerts walkthrough.

allowEvent?: boolean;

Property Value

boolean

Remarks

[ API set: Mailbox 1.12 ]

Minimum permission level (Outlook): restricted

Applicable Outlook mode: Compose

errorMessage

When you use the completed method to signal completion of an event handler and set its allowEvent property to false, this property sets the error message that will be displayed to the user. For an example, see the Smart Alerts walkthrough.

errorMessage?: string;

Property Value

string

Remarks

[ API set: Mailbox 1.12 ]

Minimum permission level (Outlook): restricted

Applicable Outlook mode: Compose