Office.MessageDecryptEventCompletedOptions interface

指定 加密加载项 在处理 完 OnMessageDecrypt 事件后的行为。

注解

API 集:邮箱 1.16

最低权限级别读/写项

适用的 Outlook 模式:邮件读取

使用方

示例

// 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" }
        }
    );
}

属性

accessControls

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventtrue时,此属性指定是否可以复制和粘贴、打印或保存消息的解密内容。

allowEvent

使用 completed 方法 指示事件处理程序完成时,此值指示事件是应继续运行还是 OnMessageDecrypt 应取消。 如果 属性 allowEvent 设置为 true,则显示消息的解密内容。

attachments

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventtrue时,此属性将设置消息的解密附件。

contextData

使用 completed 方法发出事件处理程序完成信号并将其属性true设置为 allowEvent 时,此属性将指定传递给外接程序以进行处理的任何 JSON 数据。

emailBody

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventtrue时,此属性设置消息正文的解密内容。

errorMessage

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventfalse时,此属性将设置向用户显示的错误消息。

属性详细信息

accessControls

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventtrue时,此属性指定是否可以复制和粘贴、打印或保存消息的解密内容。

accessControls?: AccessControls;

属性值

注解

API 集:邮箱预览

allowEvent

使用 completed 方法 指示事件处理程序完成时,此值指示事件是应继续运行还是 OnMessageDecrypt 应取消。 如果 属性 allowEvent 设置为 true,则显示消息的解密内容。

allowEvent: boolean;

属性值

boolean

注解

API 集:邮箱 1.16

最低权限级别读/写项

适用的 Outlook 模式:邮件读取

attachments

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventtrue时,此属性将设置消息的解密附件。

attachments?: DecryptedMessageAttachment[];

属性值

注解

API 集:邮箱 1.16

最低权限级别读/写项

适用的 Outlook 模式:邮件读取

contextData

使用 completed 方法发出事件处理程序完成信号并将其属性true设置为 allowEvent 时,此属性将指定传递给外接程序以进行处理的任何 JSON 数据。

contextData?: any;

属性值

any

注解

API 集:邮箱 1.16

最低权限级别读/写项

适用的 Outlook 模式:邮件读取

重要说明

  • 若要检索 属性的值 contextData ,必须调用 Office.context.mailbox.item.getInitializationContextAsync。 如果使用 创建 JSON 字符串 JSON.stringify() 并将其分配给 contextData 属性,则必须在检索该字符串后使用 JSON.parse() 分析该字符串。

  • 可以使用 contextData 属性来存储自定义 Internet 标头,以在答复和转发方案中解密消息。

emailBody

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventtrue时,此属性设置消息正文的解密内容。

emailBody?: DecryptedMessageBody;

属性值

注解

API 集:邮箱 1.16

最低权限级别读/写项

适用的 Outlook 模式:邮件读取

重要说明:如果未 emailBody 指定 属性,则返回空正文。

errorMessage

注意

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

使用 completed 方法 发出事件处理程序完成信号并将其属性设置为 allowEventfalse时,此属性将设置向用户显示的错误消息。

errorMessage?: string;

属性值

string

注解

API 集:邮箱预览

重要说明

  • errorMessage仅当 属性设置为 false时,allowEvent才会使用 属性。 如果将 属性 allowEvent 设置为 true,则会忽略该 errorMessage 属性。

  • 如果未在 属性中errorMessage指定消息,则会改为显示以下默认消息:“加载项名称>出错<:无法解密消息。”

  • 向用户显示时,自定义错误消息的前面会自动附加“加载项 <名称>错误: ”。