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
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;
Property Value
Examples
const item = Office.context.mailbox.item;
const options = {asyncContext: {currentItem: item}};
item.getAttachmentsAsync(options, callback);
function callback(result) {
if (result.value.length > 0) {
for (let i = 0 ; i < result.value.length ; i++) {
result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback);
}
}
}
function handleAttachmentsCallback(result) {
// Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file.
switch (result.value.format) {
case Office.MailboxEnums.AttachmentContentFormat.Base64:
// Handle file attachment.
break;
case Office.MailboxEnums.AttachmentContentFormat.Eml:
// Handle email item attachment.
break;
case Office.MailboxEnums.AttachmentContentFormat.ICalendar:
// Handle .icalender attachment.
break;
case Office.MailboxEnums.AttachmentContentFormat.Url:
// Handle cloud attachment.
break;
default:
// Handle attachment formats that are not supported.
}
}
Office Add-ins