Office.AttachmentContent interface

表示邮件或约会项目附件的内容。

注解

[ API set: Mailbox 1.8 ]

最低权限级别读取项

适用的 Outlook 模式:Compose或读取

示例

Office.context.mailbox.item.getAttachmentsAsync((result) => {
    if (result.value.length > 0) {
        for (let i = 0 ; i < result.value.length ; i++) {
            Office.context.mailbox.item.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback);
        }
    }
});

function handleAttachmentsCallback(result) {
    // Identify if an attachment is a Base64-encoded string, .eml file, .icalendar file, or a URL.
    switch (result.value.format) {
        case Office.MailboxEnums.AttachmentContentFormat.Base64:
            // Handle file attachment.
            console.log("Attachment is a Base64-encoded string.");
            break;
        case Office.MailboxEnums.AttachmentContentFormat.Eml:
            // Handle email item attachment.
            console.log("Attachment is a message.");
            break;
        case Office.MailboxEnums.AttachmentContentFormat.ICalendar:
            // Handle .icalender attachment.
            console.log("Attachment is a calendar item.");
            break;
        case Office.MailboxEnums.AttachmentContentFormat.Url:
            // Handle cloud attachment.
            console.log("Attachment is a cloud attachment.");
            break;
        default:
            // Handle attachment formats that aren't supported.
    }

    // Log the content of the attachments as a string.
    console.log(result.value.content);
}

属性

content

附件的内容作为字符串。

format

用于附件内容的字符串格式。

对于文件附件,格式设置是 Base64 编码的字符串。

对于表示邮件和通过拖放或“附加项目”附加的邮件附件,格式是表示.eml格式化文件的字符串。

对于表示日历项目且通过拖放或“附加项目”附加的项目附件,格式是表示 .icalendar 文件的字符串。

重要提示:如果邮件或日历项目是通过拖放方式附加的,Outlook 网页版或新的 Outlook on Windows,则会getAttachmentContentAsync引发错误。

对于云附件,格式为 URL 字符串。

属性详细信息

content

附件的内容作为字符串。

content: string;

属性值

string

format

用于附件内容的字符串格式。

对于文件附件,格式设置是 Base64 编码的字符串。

对于表示邮件和通过拖放或“附加项目”附加的邮件附件,格式是表示.eml格式化文件的字符串。

对于表示日历项目且通过拖放或“附加项目”附加的项目附件,格式是表示 .icalendar 文件的字符串。

重要提示:如果邮件或日历项目是通过拖放方式附加的,Outlook 网页版或新的 Outlook on Windows,则会getAttachmentContentAsync引发错误。

对于云附件,格式为 URL 字符串。

format: MailboxEnums.AttachmentContentFormat | string;

属性值