次の方法で共有


Office.MailboxEnums.AttachmentType enum

添付ファイルの種類を指定します。

注釈

適用できる Outlook モード: 新規作成または読み取り

// 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.");
  }
});

フィールド

File = "file"

この添付ファイルはファイルです。

Item = "item"

この添付ファイルは Exchange のアイテムです。

Cloud = "cloud"

添付ファイルは、OneDrive などのクラウドの場所に格納されます。

重要: 読み取りモードでは、 id 添付ファイルの details オブジェクトのプロパティにファイルの URL が含まれます。 要件セット 1.8 から、 url 添付ファイルの details オブジェクトに含まれるプロパティには、新規作成モードのファイルへの URL が含まれています。