Office.AttachmentContent interface

Represents the content of an attachment on a message or appointment item.

[ API set: Mailbox 1.8 ]

Remarks

Minimum permission level: ReadItem

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, the formatting is a string representing an .eml formatted file.

For item attachments that represent calendar items, the formatting is a string representing an .icalendar file.

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, the formatting is a string representing an .eml formatted file.

For item attachments that represent calendar items, the formatting is a string representing an .icalendar file.

For cloud attachments, the formatting is a URL string.

format: MailboxEnums.AttachmentContentFormat | string;

Property Value

Examples

var item = Office.context.mailbox.item;
var options = {asyncContext: {currentItem: item}};
item.getAttachmentsAsync(options, callback);

function callback(result) {
    if (result.value.length > 0) {
        for (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.
    }
}