Edit

Office.MessageDecryptEventCompletedOptions interface

Specifies the behavior of an encryption add-in after it completes processing an OnMessageDecrypt event.

Remarks

API set: Mailbox 1.16

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

Used by

Examples

// This sample handles the OnMessageDecrypt event to decrypt the body and attachments of a message.
function onMessageDecryptHandler(event) {
    // Your code to decrypt the contents of a message would appear here.
    ...

    // Use the results from your decryption process to display the decrypted contents of the message body and attachments.
    const decryptedBodyContent = "<p>Please find attached the recent report and its supporting documentation.</p>";
    const decryptedBody = {
        coercionType: Office.CoercionType.Html,
        content: decryptedBodyContent
    };

    // Decrypted content and properties of a file attachment.
    const decryptedPdfFile = "JVBERi0xLjQKJeLjz9MKNCAwIG9i...";
    const pdfFileName = "Fabrikam_Report_202509";

    // Decrypted properties of a cloud attachment.
    const cloudFilePath = "https://contosostorage.com/reports/weekly_forecast.xlsx";
    const cloudFileName = "weekly_forecast.xlsx";

    // Decrypted content and properties of an inline image.
    const decryptedImageFile = "iVBORw0KGgoAAAANSUhEUgAA...";
    const imageFileName = "banner.png";
    const imageContentId = "image001.png@01DC1DD9.1A4AA300";

    const decryptedAttachments = [
        {
            attachmentType: Office.MailboxEnums.AttachmentType.File,
            content: decryptedPdfFile,
            isInline: false,
            name: pdfFileName
        },
        {
            attachmentType: Office.MailboxEnums.AttachmentType.Cloud,
            isInline: false,
            name: cloudFileName,
            path: cloudFilePath
        },
        {
            attachmentType: Office.MailboxEnums.AttachmentType.File,
            content: decryptedImageFile,
            contentId: imageContentId,
            isInline: true,
            name: imageFileName
        }
    ];

    event.completed(
        {
            allowEvent: true,
            emailBody: decryptedBody,
            attachments: decryptedAttachments,
            contextData: { messageType: "ReplyFromDecryptedMessage" }
        }
    );
}

Properties

accessControls

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property specifies whether decrypted contents of a message can be copied and pasted, printed, or saved.

allowEvent

When you use the completed method to signal completion of an event handler, this value indicates if the OnMessageDecrypt event should continue to run or be canceled. If the allowEvent property is set to true, the decrypted contents of the message is displayed.

attachments

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property sets the decrypted attachments of the message.

contextData

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property specifies any JSON data passed to the add-in for processing.

emailBody

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property sets the decrypted contents of the body of the message.

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 displayed to the user.

Property Details

accessControls

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property specifies whether decrypted contents of a message can be copied and pasted, printed, or saved.

accessControls?: AccessControls;

Property Value

Remarks

API set: Mailbox preview

allowEvent

When you use the completed method to signal completion of an event handler, this value indicates if the OnMessageDecrypt event should continue to run or be canceled. If the allowEvent property is set to true, the decrypted contents of the message is displayed.

allowEvent: boolean;

Property Value

boolean

Remarks

API set: Mailbox 1.16

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

attachments

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property sets the decrypted attachments of the message.

attachments?: DecryptedMessageAttachment[];

Property Value

Remarks

API set: Mailbox 1.16

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

contextData

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property specifies any JSON data passed to the add-in for processing.

contextData?: any;

Property Value

any

Remarks

API set: Mailbox 1.16

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

Important:

  • To retrieve the value of the contextData property, you must call Office.context.mailbox.item.getInitializationContextAsync. If you create a JSON string using JSON.stringify() and assign it to the contextData property, you must parse the string using JSON.parse() once you retrieve it.

  • You can use the contextData property to store custom internet headers to decrypt messages in reply and forward scenarios.

emailBody

When you use the completed method to signal completion of an event handler and set its allowEvent property to true, this property sets the decrypted contents of the body of the message.

emailBody?: DecryptedMessageBody;

Property Value

Remarks

API set: Mailbox 1.16

Minimum permission level: read/write item

Applicable Outlook mode: Message Read

Important: If the emailBody property isn't specified, an empty body is returned.

errorMessage

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

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 displayed to the user.

errorMessage?: string;

Property Value

string

Remarks

API set: Mailbox preview

Important:

  • The errorMessage property is only used when the allowEvent property is set to false. If you set the allowEvent property to true, the errorMessage property is ignored.

  • If you don't specify a message in the errorMessage property, the following default message is shown instead: "Error from <add-in name>: Failed to decrypt your message."

  • Your custom error message is automatically prepended with "Error from <add-in name>: " when displayed to the user.