Office.AttachmentDetails interface
表示服务器中一个项目上的附件。 仅限阅读模式。
对象数组 AttachmentDetails
作为 attachments
约会或邮件项的 属性返回。
注解
最低权限级别: 读取项
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml
const item = Office.context.mailbox.item;
if (item.attachments.length > 0) {
for (let i = 0; i < item.attachments.length; i++) {
const attachment = item.attachments[i];
console.log(`${i+1}. Name: ${attachment.name}`);
console.log(`ID: ${attachment.id}`);
console.log(`Type: ${attachment.attachmentType}`);
console.log(`Inline content: ${attachment.isInline}`);
console.log(`Size: ${attachment.size}`);
}
} else {
console.log("This mail item doesn't contain any attachments.");
}
属性
attachment |
获取一个值,该值指示附件的类型。 |
content |
获取附件的 MIME 内容类型。
警告:虽然 |
id | 获取附件的 Exchange 附件 ID。 但是,如果附件类型为 |
is |
获取一个值,该值指示附件在项目正文中而不是附件列表中是否显示为图像。 |
name | 获取附件的名称。
重要提示:对于通过拖放或“附加项目”附加的邮件或约会项目, |
size | 获取以字节为单位的附件大小。 |
属性详细信息
attachmentType
获取一个值,该值指示附件的类型。
attachmentType: MailboxEnums.AttachmentType | string;
属性值
Office.MailboxEnums.AttachmentType | string
contentType
警告
现已弃用此 API。
If you require specific content types, grab the attachment's extension and process accordingly.
获取附件的 MIME 内容类型。
警告:虽然 contentType
该值是附件扩展的直接查找,但内部映射不会主动维护,因此此属性已被弃用。 如果需要特定类型,请获取附件的扩展并相应地处理。 有关详细信息,请参阅 相关博客文章。
contentType: string;
属性值
string
id
获取附件的 Exchange 附件 ID。 但是,如果附件类型为 MailboxEnums.AttachmentType.Cloud
,则返回文件的 URL。
id: string;
属性值
string
isInline
获取一个值,该值指示附件在项目正文中而不是附件列表中是否显示为图像。
isInline: boolean;
属性值
boolean
name
获取附件的名称。
重要提示:对于通过拖放或“附加项目”附加的邮件或约会项目, name
在 Outlook on Mac 中包含文件扩展名,但不包括 Web 或 Windows 上的扩展。
name: string;
属性值
string
size
获取以字节为单位的附件大小。
size: number;
属性值
number