Office.AttachmentDetailsCompose interface
表示项目上的附件。 仅限撰写模式。
对象数组 AttachmentDetailsCompose 由 getAttachmentsAsync 方法返回。
注解
最低权限级别: 读取项
适用的 Outlook 模式:Compose
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/attachments-compose.yaml
Office.context.mailbox.item.getAttachmentsAsync((result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(result.error.message);
return;
}
if (result.value.length > 0) {
for (let i = 0; i < result.value.length; i++) {
const attachment = result.value[i];
let attachmentType;
switch (attachment.attachmentType) {
case Office.MailboxEnums.AttachmentType.Cloud:
attachmentType = "Attachment is stored in a cloud location";
break;
case Office.MailboxEnums.AttachmentType.File:
attachmentType = "Attachment is a file";
break;
case Office.MailboxEnums.AttachmentType.Item:
attachmentType = "Attachment is an Exchange item";
break;
}
console.log(
"ID: " +
attachment.id +
"\n" +
"Type: " +
attachmentType +
"\n" +
"Name: " +
attachment.name +
"\n" +
"Size: " +
attachment.size +
"\n" +
"isInline: " +
attachment.isInline
);
}
} else {
console.log("No attachments on this message.");
}
});
属性
| attachment |
获取一个值,该值指示附件的类型。 |
| content |
获取内联附件的内容标识符。 |
| id | 获取附件的索引。 |
| is |
获取一个值,该值指示附件在项目正文中而不是附件列表中是否显示为图像。 |
| name | 获取附件的名称。 |
| size | 获取以字节为单位的附件大小。 |
| url | 如果附件的类型为 |
属性详细信息
attachmentType
获取一个值,该值指示附件的类型。
attachmentType: MailboxEnums.AttachmentType | string;
属性值
Office.MailboxEnums.AttachmentType | string
注解
重要说明:
在Outlook 网页版和新的 Outlook on Windows 中,本地保存的邮件或约会,然后使用拖放或“附加项目”选项进行附加, 类型
Office.MailboxEnums.AttachmentType.File为 。 文件扩展名在 属性中name返回。 但是,使用 “转发为附件 ”选项附加的邮件或约会的类型Office.MailboxEnums.AttachmentType.Item为 。 在这种情况下,不会在 属性中name返回扩展。在经典 Outlook on Windows 中,使用拖放、 附加文件或 作为附件转发 附加的邮件或约会的类型
Office.MailboxEnums.AttachmentType.Item为 。 属性中name不返回文件扩展名。在 Outlook on Mac 中,使用拖放、 附加项目或 转发作为附件附加 的邮件或约会的类型
Office.MailboxEnums.AttachmentType.File为 。 文件扩展名在 属性中name返回。
contentId
获取内联附件的内容标识符。
contentId: string;
属性值
string
注解
重要说明:
属性
contentId仅在 Outlook 网页版 和 Windows 上的 Outlook 中受支持, (新的和经典 (预览版) ) 。 若要在经典 Outlook on Windows 中预览contentId属性,Outlook 客户端必须运行版本 2510 (内部版本 19312.20000) 或更高版本,并且必须在 Beta 频道上。 有关详细信息,请参阅 Microsoft 365 预览体验计划。从 2025 年 11 月 15 日开始,更改内联图像在 Outlook 网页版 中 Outlook 电子邮件的 HTML 正文中的表示方式,新的 Windows 版 Outlook 将开始向生产用户推出。 以前,图像的附件 ID 显示在适用
<img>元素的 属性中src。 更改后,图像将由属性中src的内容 ID (cid) 来表示。 因此,如果从 HTML 编辑器分析附件 ID,或者从 属性中的 URLsrc获取图像的 Base64 值,则需要更新加载项分析逻辑。 有关详细信息,请参阅更改Outlook 网页版中的内联图像表示形式和新的 Outlook for Windows。
id
获取附件的索引。
id: string;
属性值
string
isInline
获取一个值,该值指示附件在项目正文中而不是附件列表中是否显示为图像。
isInline: boolean;
属性值
boolean
name
获取附件的名称。
name: string;
属性值
string
注解
重要说明:
类型的
Office.MailboxEnums.AttachmentType.Item附件不会在 属性中name返回文件扩展名。在Outlook 网页版和新的 Outlook on Windows 中,本地保存的邮件或约会,然后使用拖放或“附加项目”选项进行附加, 类型
Office.MailboxEnums.AttachmentType.File为 。 文件扩展名在 属性中name返回。 但是,使用 “转发为附件 ”选项附加的邮件或约会的类型Office.MailboxEnums.AttachmentType.Item为 。 在这种情况下,不会在 属性中name返回扩展。在经典 Outlook on Windows 中,使用拖放、 附加文件或 作为附件转发 附加的邮件或约会的类型
Office.MailboxEnums.AttachmentType.Item为 。 属性中name不返回文件扩展名。在 Outlook on Mac 中,使用拖放、 附加项目或 转发作为附件附加 的邮件或约会的类型
Office.MailboxEnums.AttachmentType.File为 。 文件扩展名在 属性中name返回。
size
获取以字节为单位的附件大小。
size: number;
属性值
number
url
如果附件的类型为 MailboxEnums.AttachmentType.Cloud,则获取其 URL。
url?: string;
属性值
string