Office.DragAndDropEventArgs interface

提供有关引发事件时 Office.EventType.DragAndDropEvent 鼠标指针位置以及拖放到加载项任务窗格中的邮件或文件附件的详细信息。

注解

[ 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); })}`);
      });
    }
  });
}

属性

dragAndDropEventData

获取有关加载项任务窗格中的鼠标指针位置以及正在拖放到任务窗格中的邮件或文件附件的详细信息。

type

获取事件的类型。 有关详细信息,请参阅 Office.EventType

[ API 集:邮箱 1.5 ]

属性详细信息

dragAndDropEventData

获取有关加载项任务窗格中的鼠标指针位置以及正在拖放到任务窗格中的邮件或文件附件的详细信息。

dragAndDropEventData: DragoverEventData | DropEventData;

属性值

注解

[ API 集:邮箱 1.5 ]

type

获取事件的类型。 有关详细信息,请参阅 Office.EventType

[ API 集:邮箱 1.5 ]

type: "olkDragAndDropEvent";

属性值

"olkDragAndDropEvent"