Office.DroppedItemDetails interface

提供要拖放到加载项任务窗格中的邮件或文件附件的内容和详细信息。

注解

[ API 集:邮箱 1.5 ]

若要详细了解拖放功能以及如何跨各种 Outlook 客户端实现该功能,请参阅 将邮件和附件拖放到 Outlook 外接程序的任务窗格中。

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/80-events/drag-drop-item.yaml

function dragAndDropEventHandler(event) {
    Office.context.mailbox.addHandlerAsync(Office.EventType.DragAndDropEvent, (event) => {
    console.log(`Event type: ${event.type}`);

    const eventData = event.dragAndDropEventData;
    console.log(`x-coordinate: ${eventData.pageX}, y-coordinate: ${eventData.pageY}`);

    if (eventData.type == "drop") {
      console.log("Items dropped into task pane.");
      const files = eventData.dataTransfer.files;
      files.forEach((file) => {
        const content = file.fileContent;
        const name = file.name;
        const fileType = file.type;
        console.log(`File name: ${name}`);
        console.log(`File type: ${fileType}`);
        console.log(`Contents: ${content.text().then((text) => { console.log(text); })}`);
      });
    }
  });
}

属性

fileContent

获取要拖放的文件的内容。

name

获取要拖放的文件的名称。

type

获取要拖放的文件的类型。

属性详细信息

fileContent

获取要拖放的文件的内容。

fileContent: Blob;

属性值

Blob

注解

[ API 集:邮箱 1.5 ]

有关如何从 Blob检索数据的指南,请参阅 文件 API 文档

name

获取要拖放的文件的名称。

name: string;

属性值

string

注解

[ API 集:邮箱 1.5 ]

type

获取要拖放的文件的类型。

type: string;

属性值

string

注解

[ API 集:邮箱 1.5 ]

重要提示:将消息拖动到加载项的任务窗格中时,会将其作为.eml文件删除。