Office.MessageDecryptEventCompletedOptions interface
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.
Specifies the behavior of an encryption add-in after it completes processing an OnMessageRead event.
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
Examples
// This sample handles the OnMessageRead event to decrypt the body and attachments of a message.
function onMessageReadHandler(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 content and properties of a mail item.
const decryptedEmailFile = "VGhpcyBpcyBhIHRleHQgZmlsZS4=...";
const emailFileName = "Fabrikam_Report_202508.eml";
// 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.Item,
content: decryptedEmailFile,
isInline: false,
name: emailFileName
},
{
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
| allow |
When you use the completed method to signal completion of an event handler, this value indicates if the |
| attachments | When you use the completed method to signal completion of an event handler and set its |
| context |
When you use the completed method to signal completion of an event handler and set its |
| email |
When you use the completed method to signal completion of an event handler and set its |
Property Details
allowEvent
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, this value indicates if the OnMessageRead 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
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
attachments
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 sets the decrypted attachments of the message.
attachments?: DecryptedMessageAttachment[];
Property Value
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
contextData
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 any JSON data passed to the add-in for processing.
contextData?: any;
Property Value
any
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
Important:
To retrieve the value of the
contextDataproperty, you must callOffice.context.mailbox.item.getInitializationContextAsync. If you create a JSON string usingJSON.stringify()and assign it to thecontextDataproperty, you must parse the string usingJSON.parse()once you retrieve it.You can use the
contextDataproperty to store custom internet headers to decrypt messages in reply and forward scenarios.
emailBody
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 sets the decrypted contents of the body of the message.
emailBody?: DecryptedMessageBody;
Property Value
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
Important: If the emailBody property isn't specified, an empty body is returned.