Office.EnhancedLocation interface

表示约会上的位置集。

注解

API 集:邮箱 1.8

最低权限级别读取项目

适用的 Outlook 模式:Compose 或 Read

重要提示:若要在不支持邮箱要求集 1.8 的 Outlook 客户端中管理约会位置,请改用 Office.Location API。 有关为方案选择正确的位置 API 的指南,请参阅“在 Outlook 中撰写指定内容时获取或设置位置”。

使用方

方法

addAsync(locationIdentifiers, options, callback)

添加到与约会关联的位置集。

addAsync(locationIdentifiers, callback)

添加到与约会关联的位置集。

getAsync(options, callback)

获取与约会关联的位置集。

getAsync(callback)

获取与约会关联的位置集。

removeAsync(locationIdentifiers, options, callback)

删除与约会关联的位置集。

如果有多个同名的位置,则即使只 locationIdentifiers指定了一个位置,也将删除所有匹配的位置。

removeAsync(locationIdentifiers, callback)

删除与约会关联的位置集。

如果有多个同名的位置,则即使只 locationIdentifiers指定了一个位置,也将删除所有匹配的位置。

方法详细信息

addAsync(locationIdentifiers, options, callback)

添加到与约会关联的位置集。

addAsync(locationIdentifiers: LocationIdentifier[], options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

locationIdentifiers

Office.LocationIdentifier[]

要添加到当前位置列表中的位置。

options
Office.AsyncContextOptions

包含以下一个或多个属性的对象文本:- asyncContext:开发人员可以在回调函数中提供他们希望访问的任何对象。

callback

(asyncResult: Office.AsyncResult<void>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 检查 statusasyncResult 属性以确定调用是否成功。

返回

void

注解

API 集:邮箱 1.8

最低权限级别读取/写入项目

适用的 Outlook 模式:Compose

错误

  • InvalidFormatError :指定数据对象的格式无效。

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml

const locations = [
  {
    id: "Contoso",
    type: Office.MailboxEnums.LocationType.Custom
  },
  {
    id: "room500@test.com",
    type: Office.MailboxEnums.LocationType.Room
  }
];
Office.context.mailbox.item.enhancedLocation.addAsync(locations, (result) => {
  if (result.status === Office.AsyncResultStatus.Succeeded) {
    console.log(`Successfully added locations ${JSON.stringify(locations)}`);
  } else {
    console.error(`Failed to add locations. Error message: ${result.error.message}`);
  }
});

addAsync(locationIdentifiers, callback)

添加到与约会关联的位置集。

addAsync(locationIdentifiers: LocationIdentifier[], callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

locationIdentifiers

Office.LocationIdentifier[]

要添加到当前位置列表中的位置。

callback

(asyncResult: Office.AsyncResult<void>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 检查 statusasyncResult 属性以确定调用是否成功。

返回

void

注解

API 集:邮箱 1.8

最低权限级别读取/写入项目

适用的 Outlook 模式:Compose

错误

  • InvalidFormatError :指定数据对象的格式无效。

getAsync(options, callback)

获取与约会关联的位置集。

getAsync(options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<LocationDetails[]>) => void): void;

参数

options
Office.AsyncContextOptions

包含以下一个或多个属性的对象文本:- asyncContext:开发人员可以在回调函数中提供他们希望访问的任何对象。

callback

(asyncResult: Office.AsyncResult<Office.LocationDetails[]>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 在属性中asyncResult.value返回表示约会位置的对象数Office.LocationDetails组。

返回

void

注解

API 集:邮箱 1.8

最低权限级别读取项目

适用的 Outlook 模式:Compose 或 Read

重要说明

  • getAsync方法不会返回已添加到约会的位置字段的个人联系人组

  • 如果位置是使用 Office.context.mailbox.item.location.setAsync添加的,则其位置类型为 Office.MailboxEnums.LocationType.Custom

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml

Office.context.mailbox.item.enhancedLocation.getAsync((result) => {
  if (result.status !== Office.AsyncResultStatus.Succeeded) {
    console.error(`Failed to get locations. Error message: ${result.error.message}`);
    return;
  }
  const places = result.value;
  if (places && places.length > 0) {
    result.value.forEach(function(place) {
      console.log(`Location: ${place.displayName} (type: ${place.locationIdentifier.type})`);
      if (place.locationIdentifier.type === Office.MailboxEnums.LocationType.Room) {
        console.log("Email address: " + place.emailAddress);
      }
    });
  } else {
    console.log("There are no locations.");
  }
});

getAsync(callback)

获取与约会关联的位置集。

getAsync(callback?: (asyncResult: Office.AsyncResult<LocationDetails[]>) => void): void;

参数

callback

(asyncResult: Office.AsyncResult<Office.LocationDetails[]>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 在属性中asyncResult.value返回表示约会位置的对象数Office.LocationDetails组。

返回

void

注解

API 集:邮箱 1.8

最低权限级别读取项目

适用的 Outlook 模式:Compose 或 Read

重要说明

  • getAsync方法不会返回已添加到约会的位置字段的个人联系人组

  • 如果位置是使用 Office.context.mailbox.item.location.setAsync添加的,则其位置类型为 Office.MailboxEnums.LocationType.Custom

removeAsync(locationIdentifiers, options, callback)

删除与约会关联的位置集。

如果有多个同名的位置,则即使只 locationIdentifiers指定了一个位置,也将删除所有匹配的位置。

removeAsync(locationIdentifiers: LocationIdentifier[], options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

locationIdentifiers

Office.LocationIdentifier[]

要从当前位置列表中删除的位置。

options
Office.AsyncContextOptions

包含以下一个或多个属性的对象文本:- asyncContext:开发人员可以在回调函数中提供他们希望访问的任何对象。

callback

(asyncResult: Office.AsyncResult<void>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 检查 statusasyncResult 属性以确定调用是否成功。

返回

void

注解

API 集:邮箱 1.8

最低权限级别读取/写入项目

适用的 Outlook 模式:Compose

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-add-remove-enhancedlocation-appointment.yaml

const locations = [
  {
    id: "Contoso",
    type: Office.MailboxEnums.LocationType.Custom
  },
  {
    id: "room500@test.com",
    type: Office.MailboxEnums.LocationType.Room
  }
];
Office.context.mailbox.item.enhancedLocation.removeAsync(locations, (result) => {
  if (result.status === Office.AsyncResultStatus.Succeeded) {
    console.log(`Successfully removed locations ${JSON.stringify(locations)}`);
  } else {
    console.error(`Failed to remove locations. Error message: ${result.error.message}`);
  }
});

removeAsync(locationIdentifiers, callback)

删除与约会关联的位置集。

如果有多个同名的位置,则即使只 locationIdentifiers指定了一个位置,也将删除所有匹配的位置。

removeAsync(locationIdentifiers: LocationIdentifier[], callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

locationIdentifiers

Office.LocationIdentifier[]

要从当前位置列表中删除的位置。

callback

(asyncResult: Office.AsyncResult<void>) => void

可选。 当该方法完成时,将使用单个参数(一个对象)asyncResultOffice.AsyncResult调用传入参数的callback函数。 检查 statusasyncResult 属性以确定调用是否成功。

返回

void

注解

API 集:邮箱 1.8

最低权限级别读取/写入项目

适用的 Outlook 模式:Compose