Office.AttachmentContent interface
表示邮件或约会项目上附件的内容。
注解
最低权限级别: 读取项目
适用的 Outlook 模式:Compose 或 Read
使用方
- Office.AppointmentCompose: getAttachmentContentAsync
- Office.AppointmentRead: getAttachmentContentAsync
- Office.LoadedMessageCompose: getAttachmentContentAsync
- Office.LoadedMessageRead: getAttachmentContentAsync
- Office.MessageCompose: getAttachmentContentAsync
- Office.MessageRead: getAttachmentContentAsync
示例
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 网页版或 Windows 上的新版 Outlook 中通过拖放方式附加邮件或日历项目, 对于云附件,格式设置为 URL 字符串。 |
属性详细信息
content
字符串形式的附件内容。
content: string;
属性值
string
format
要用于附件内容的字符串格式。
对于文件附件,格式是 Base64 编码的字符串。
对于表示邮件且通过拖放或“附加项目”附加的项目附件,格式为表示.eml格式文件的字符串。
对于表示日历项目并通过拖放或“附加项目”附加的项目附件,格式为表示 .icalendar 文件的字符串。
重要提示:如果在 Outlook 网页版或 Windows 上的新版 Outlook 中通过拖放方式附加邮件或日历项目,getAttachmentContentAsync则会引发错误。
对于云附件,格式设置为 URL 字符串。
format: MailboxEnums.AttachmentContentFormat | string;