Office.MailboxEnums.AttachmentType enum

Specifies an attachment's type.

Remarks

Applicable Outlook mode: Compose or Read

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

Fields

File = "file"

The attachment is a file.

Item = "item"

The attachment is an Exchange item.

Cloud = "cloud"

The attachment is stored in a cloud location, such as OneDrive.

Important: In Read mode, the id property of the attachment's details object contains a URL to the file. From requirement set 1.8, the url property included in the attachment's details object contains a URL to the file in Compose mode.