Edit

Share via


Office.AttachmentDetails interface

Represents an attachment on an item from the server. Read mode only.

An array of AttachmentDetails objects is returned as the attachments property of an appointment or message item.

Remarks

[ API set: Mailbox 1.1 ]

Minimum permission level: read item

Applicable Outlook mode: Read

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml

const item = Office.context.mailbox.item;

if (item.attachments.length > 0) {
    for (let i = 0; i < item.attachments.length; i++) {
        const attachment = item.attachments[i];
        console.log(`${i+1}. Name: ${attachment.name}`);
        console.log(`ID: ${attachment.id}`);
        console.log(`Type: ${attachment.attachmentType}`);
        console.log(`Inline content: ${attachment.isInline}`);
        console.log(`Size: ${attachment.size}`);
    }
} else {
    console.log("This mail item doesn't contain any attachments.");
}

Properties

attachmentType

Gets a value that indicates the attachment's type.

contentId

Gets the content identifier of an inline attachment.

contentType

Gets the MIME content type of the attachment.

Warning: While the contentType value is a direct lookup of the attachment's extension, the internal mapping isn't actively maintained so this property has been deprecated. If you require specific types, grab the attachment's extension and process accordingly. For details, refer to the related blog post.

id

Gets the Exchange attachment ID of the attachment. However, if the attachment type is MailboxEnums.AttachmentType.Cloud, then a URL for the file is returned.

isInline

Gets a value that indicates whether the attachment appears as an image in the body of the item instead of in the attachment list.

name

Gets the name of the attachment.

size

Gets the size of the attachment in bytes.

Property Details

attachmentType

Gets a value that indicates the attachment's type.

attachmentType: MailboxEnums.AttachmentType | string;

Property Value

contentId

Gets the content identifier of an inline attachment.

contentId: string;

Property Value

string

Remarks

Important:

  • The contentId property is only supported in Outlook on the web, the new Outlook on Windows, and classic Outlook on Windows (preview). To preview the contentId property in classic Outlook on Windows, your Outlook client must run Version 2510 (Build 19312.20000) or later and must be on the Beta Channel. For more information, see Microsoft 365 Insider Program.

  • Changes to how inline images are represented in the HTML body of Outlook emails in Outlook on the web and the new Outlook on Windows released on November 15, 2025. Previously, the attachment ID of the image appeared in the src attribute of the applicable <img> element. Now, the image is represented by a content ID (cid) in the src attribute instead. If you parse the attachment ID from the HTML editor or get the Base64-encoded value of the image from the URL in the src attribute, you must update your add-in's parsing logic. For more information, see Changes to inline image representation in Outlook on the web and new Outlook for Windows.

contentType

Warning

This API is now deprecated.

If you require specific content types, grab the attachment's extension and process accordingly.

Gets the MIME content type of the attachment.

Warning: While the contentType value is a direct lookup of the attachment's extension, the internal mapping isn't actively maintained so this property has been deprecated. If you require specific types, grab the attachment's extension and process accordingly. For details, refer to the related blog post.

contentType: string;

Property Value

string

id

Gets the Exchange attachment ID of the attachment. However, if the attachment type is MailboxEnums.AttachmentType.Cloud, then a URL for the file is returned.

id: string;

Property Value

string

isInline

Gets a value that indicates whether the attachment appears as an image in the body of the item instead of in the attachment list.

isInline: boolean;

Property Value

boolean

name

Gets the name of the attachment.

name: string;

Property Value

string

Remarks

Important: An attachment of type Office.MailboxEnums.AttachmentType.Item doesn't return a file name extension in the name property.

size

Gets the size of the attachment in bytes.

size: number;

Property Value

number