Office.DecryptedMessageAttachment interface

表示解密邮件中的附件。

注解

API 集:邮箱 1.16

最低权限级别读取/写入项目

适用的 Outlook 模式:消息阅读

若要了解如何在 Outlook 中开发加密加载项,请参阅 创建加密 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" }
        }
    );
}

属性

attachmentType

指定附件的类型。

content

指定附件的 Base64 编码内容。

contentId

指定内联附件的内容标识符。

如果设置为 true,则isInline必须指定该contentId属性。

isInline

如果为 true,则指定解密的附件在邮件正文中而不是附件列表中显示为图像。 如果未指定该 isInline 属性,则其值设置为 false。

name

指定附件的名称。

path

指定附件的 URL 引用路径(如果附件类型 MailboxEnums.AttachmentType.Cloud为 )。 必须为类型的MailboxEnums.AttachmentType.Cloud附件指定该path属性。

属性详细信息

attachmentType

指定附件的类型。

attachmentType: MailboxEnums.AttachmentType;

属性值

注解

API 集:邮箱 1.16

最低权限级别读取/写入项目

适用的 Outlook 模式:消息阅读

重要提示: 生产环境中当前不支持类型的 MailboxEnums.AttachmentType.Item 附件。 但是,可以在 Outlook 网页版 和 Windows 上预览对该MailboxEnums.AttachmentType.Item类型的支持, (新的和经典的) 。 对于 Windows 上的经典 Outlook,必须安装版本 2606 (内部版本 20114.15110) 或更高版本。 然后,加入 Microsoft 365 预览体验计划 并选择 Beta 版频道 选项以访问 Office Beta 版本。

content

指定附件的 Base64 编码内容。

content: string;

属性值

string

注解

API 集:邮箱 1.16

最低权限级别读取/写入项目

适用的 Outlook 模式:消息阅读

重要提示: 类型MailboxEnums.AttachmentType.Cloud为 . 的附件不支持此content属性。

contentId

指定内联附件的内容标识符。

如果设置为 true,则isInline必须指定该contentId属性。

contentId?: string;

属性值

string

注解

API 集:邮箱 1.16

最低权限级别读取/写入项目

适用的 Outlook 模式:消息阅读

重要提示:当图片作为内嵌附件添加到邮件中时,系统会自动为它们分配内容 ID。 在邮件正文中,元素 (的属性<img>src指定内联附件的内容 ID,例如 <img width=96 height=96 id="Picture_1" src="cid:image001.png@01DC1E6F.FC7C7410">) 。 为了在解密过程中轻松识别和提供这些内联附件,建议在加密期间将内联附件的内容 ID 保存到邮件头。 调用 Office.context.mailbox.item.getAttachmentsAsync 以获取内联附件的内容 ID。 然后,调用 Office.context.mailbox.item.internetHeaders.setAsync 以将 ID 保存到消息的标题。

isInline

如果为 true,则指定解密的附件在邮件正文中而不是附件列表中显示为图像。 如果未指定该 isInline 属性,则其值设置为 false。

isInline?: boolean;

属性值

boolean

注解

API 集:邮箱 1.16

最低权限级别读取/写入项目

适用的 Outlook 模式:消息阅读

name

指定附件的名称。

name: string;

属性值

string

注解

API 集:邮箱 1.16

最低权限级别读取/写入项目

适用的 Outlook 模式:消息阅读

path

指定附件的 URL 引用路径(如果附件类型 MailboxEnums.AttachmentType.Cloud为 )。 必须为类型的MailboxEnums.AttachmentType.Cloud附件指定该path属性。

path?: string;

属性值

string

注解

API 集:邮箱 1.16

最低权限级别读取/写入项目

适用的 Outlook 模式:消息阅读