Office.AttachmentContent interface
Represents the content of an attachment on a message or appointment item.
Remarks
Minimum permission level: read item
Applicable Outlook mode: Compose or Read
Examples
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);
}
Properties
content | The content of an attachment as a string. |
format | The string format to use for an attachment's content. For file attachments, the formatting is a Base64-encoded string. For item attachments that represent messages and were attached by drag-and-drop or "Attach Item", the formatting is a string representing an .eml formatted file. For item attachments that represent calendar items and were attached by drag-and-drop or "Attach Item", the formatting is a string representing an .icalendar file. Important: If a message or calendar item was attached by drag-and-drop in Outlook on the web or new Outlook on Windows, then For cloud attachments, the formatting is a URL string. |
Property Details
content
The content of an attachment as a string.
content: string;
Property Value
string
format
The string format to use for an attachment's content.
For file attachments, the formatting is a Base64-encoded string.
For item attachments that represent messages and were attached by drag-and-drop or "Attach Item", the formatting is a string representing an .eml formatted file.
For item attachments that represent calendar items and were attached by drag-and-drop or "Attach Item", the formatting is a string representing an .icalendar file.
Important: If a message or calendar item was attached by drag-and-drop in Outlook on the web or new Outlook on Windows, then getAttachmentContentAsync
throws an error.
For cloud attachments, the formatting is a URL string.
format: MailboxEnums.AttachmentContentFormat | string;