Edit

Share via


Office.AttachmentDetailsCompose interface

Represents an attachment on an item. Compose mode only.

An array of AttachmentDetailsCompose objects is returned by the getAttachmentsAsync method.

Remarks

[ API set: Mailbox 1.8 ]

Minimum permission level: read item

Applicable Outlook mode: Compose

Examples

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

Office.context.mailbox.item.getAttachmentsAsync((result) => {
  if (result.status === Office.AsyncResultStatus.Failed) {
    console.error(result.error.message);
    return;
  }

  if (result.value.length > 0) {
    for (let i = 0; i < result.value.length; i++) {
      const attachment = result.value[i];
      let attachmentType;
      switch (attachment.attachmentType) {
        case Office.MailboxEnums.AttachmentType.Cloud:
          attachmentType = "Attachment is stored in a cloud location";
          break;
        case Office.MailboxEnums.AttachmentType.File:
          attachmentType = "Attachment is a file";
          break;
        case Office.MailboxEnums.AttachmentType.Item:
          attachmentType = "Attachment is an Exchange item";
          break;
      }
      console.log(
        "ID: " +
          attachment.id +
          "\n" +
          "Type: " +
          attachmentType +
          "\n" +
          "Name: " +
          attachment.name +
          "\n" +
          "Size: " +
          attachment.size +
          "\n" +
          "isInline: " +
          attachment.isInline
      );
    }
  } else {
    console.log("No attachments on this message.");
  }
});

Properties

attachmentType

Gets a value that indicates the attachment's type.

contentId

Gets the content identifier of an inline attachment.

id

Gets the identifier of an attachment. The value varies depending on the Outlook client.

  • In Outlook on the web and the new Outlook on Windows, the identifier is the Exchange Web Services (EWS) ID. For inline attachments, the initial identifier is a temporary attachment ID, prefixed with addinId, while the attachment is uploaded to the server. Once the upload completes, the attachment receives an EWS ID. For details, see the notes in the Remarks section.

  • In Outlook on Windows (classic) and on Mac, the identifier for inline and non-inline attachments is the index of the attachment.

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.

isServiceAccessible

In Outlook on the web and the new Outlook on Windows, indicates whether an inline attachment in a message has been uploaded to the server and assigned an Exchange Web Services (EWS) ID.

name

Gets the name of the attachment.

size

Gets the size of the attachment in bytes.

url

Gets the url of the attachment if its type is MailboxEnums.AttachmentType.Cloud.

Property Details

attachmentType

Gets a value that indicates the attachment's type.

attachmentType: MailboxEnums.AttachmentType | string;

Property Value

Remarks

Important:

  • In Outlook on the web and new Outlook on Windows, a message or appointment that's locally saved then attached using drag-and-drop or the Attach Item option is of type Office.MailboxEnums.AttachmentType.File. The file name extension is returned in the name property. However, a message or appointment that's attached using the Forward as Attachment option is of type Office.MailboxEnums.AttachmentType.Item. In this case, an extension isn't returned in the name property.

  • In classic Outlook on Windows, a message or appointment that's attached using drag-and-drop, Attach File, or Forward as Attachment is of type Office.MailboxEnums.AttachmentType.Item. A file name extension isn't returned in the name property.

  • In Outlook on Mac, a message or appointment that's attached using drag-and-drop, Attach Item, or Forward as Attachment is of type Office.MailboxEnums.AttachmentType.File. The file name extension is returned in the name property.

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.

id

Gets the identifier of an attachment. The value varies depending on the Outlook client.

  • In Outlook on the web and the new Outlook on Windows, the identifier is the Exchange Web Services (EWS) ID. For inline attachments, the initial identifier is a temporary attachment ID, prefixed with addinId, while the attachment is uploaded to the server. Once the upload completes, the attachment receives an EWS ID. For details, see the notes in the Remarks section.

  • In Outlook on Windows (classic) and on Mac, the identifier for inline and non-inline attachments is the index of the attachment.

id: string;

Property Value

string

Remarks

Important: Starting March 30, 2026, after the call to addFileAttachmentAsync or addFileAttachmentFromBase64Async with isInline set to true completes, inline images in messages in Outlook on the web and the new Outlook on Windows are locally assigned a temporary attachment ID while they're uploaded to the server. A temporary attachment ID is prefixed with addinId. Once the images are uploaded to the server, they are then assigned an Exchange Web Services (EWS) ID. The temporary attachment ID is only supported for the duration of the current compose session. For more information on the changes to how inline images are handled, see Changes to attachment IDs for inline images in Outlook add-ins.

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

isServiceAccessible

In Outlook on the web and the new Outlook on Windows, indicates whether an inline attachment in a message has been uploaded to the server and assigned an Exchange Web Services (EWS) ID.

isServiceAccessible: boolean;

Property Value

boolean

Remarks

Important:

  • Starting March 30, 2026, after the call to addFileAttachmentAsync or addFileAttachmentFromBase64Async with isInline set to true completes, inline images in Outlook on the web and the new Outlook on Windows are locally assigned a temporary attachment ID while they're uploaded to the server. A temporary attachment ID is prefixed with addinId. Once the images are uploaded to the server, they are then assigned an Exchange Web Services (EWS) ID in the id property and their isServiceAccessible property is set to true. The temporary attachment ID is only supported for the duration of the current compose session. For more information on the changes to how inline images are handled, see Changes to attachment IDs for inline images in Outlook add-ins.

  • In Outlook on Windows (classic) and on Mac, the isServiceAccessible property always returns false since the attachment ID is the index of the attachment.

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.

  • In Outlook on the web and new Outlook on Windows, a message or appointment that's locally saved then attached using drag-and-drop or the Attach Item option is of type Office.MailboxEnums.AttachmentType.File. The file name extension is returned in the name property. However, a message or appointment that's attached using the Forward as Attachment option is of type Office.MailboxEnums.AttachmentType.Item. In this case, an extension isn't returned in the name property.

  • In classic Outlook on Windows, a message or appointment that's attached using drag-and-drop, Attach File, or Forward as Attachment is of type Office.MailboxEnums.AttachmentType.Item. A file name extension isn't returned in the name property.

  • In Outlook on Mac, a message or appointment that's attached using drag-and-drop, Attach Item, or Forward as Attachment is of type Office.MailboxEnums.AttachmentType.File. The file name extension is returned in the name property.

size

Gets the size of the attachment in bytes.

size: number;

Property Value

number

url

Gets the url of the attachment if its type is MailboxEnums.AttachmentType.Cloud.

url?: string;

Property Value

string