Office.Location interface

提供用于获取和设置 Outlook 外接程序中的会议地点的方法。

注解

API 集:邮箱 1.1

最低权限级别读取项目

适用的 Outlook 模式:Compose

重要提示: Office.EnhancedLocation API 已在邮箱要求集 1.8 中引入。 使用 EnhancedLocation API 更好地识别和管理约会位置,尤其是在需要确定位置类型时。 有关为方案选择正确的位置 API 的指南,请参阅“在 Outlook 中撰写指定内容时获取或设置位置”。

使用方

方法

getAsync(options, callback)

获取约会的位置。

getAsync 方法开始对 Exchange 服务器进行异步调用,以获取约会的位置。 约会位置在属性中 asyncResult.value 以字符串形式提供。

getAsync(callback)

获取约会的位置。

getAsync 方法开始对 Exchange 服务器进行异步调用,以获取约会的位置。 约会位置在属性中 asyncResult.value 以字符串形式提供。

setAsync(location, options, callback)

设置约会的位置。

setAsync 方法开始对 Exchange 服务器进行异步调用,以设置约会的位置。 设置约会的位置将覆盖当前位置。

setAsync(location, callback)

设置约会的位置。

setAsync 方法开始对 Exchange 服务器进行异步调用,以设置约会的位置。 设置约会的位置将覆盖当前位置。

方法详细信息

getAsync(options, callback)

获取约会的位置。

getAsync 方法开始对 Exchange 服务器进行异步调用,以获取约会的位置。 约会位置在属性中 asyncResult.value 以字符串形式提供。

getAsync(options: Office.AsyncContextOptions, callback: (asyncResult: Office.AsyncResult<string>) => void): void;

参数

options
Office.AsyncContextOptions

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

callback

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

当该方法完成时, callback 将使用类型 Office.AsyncResult为 .

返回

void

注解

API 集:邮箱 1.1

最低权限级别读取项目

适用的 Outlook 模式:Compose

示例

const userContext = { value : 1 };
Office.context.mailbox.item.location.getAsync( { context: userContext}, callback);

function callback(asyncResult) {
    const context = asyncResult.context;
    const location = asyncResult.value;
}

getAsync(callback)

获取约会的位置。

getAsync 方法开始对 Exchange 服务器进行异步调用,以获取约会的位置。 约会位置在属性中 asyncResult.value 以字符串形式提供。

getAsync(callback: (asyncResult: Office.AsyncResult<string>) => void): void;

参数

callback

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

当该方法完成时, callback 将使用类型 Office.AsyncResult为 .

返回

void

注解

API 集:邮箱 1.1

最低权限级别读取项目

适用的 Outlook 模式:Compose

示例

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

Office.context.mailbox.item.location.getAsync((result) => {
  if (result.status !== Office.AsyncResultStatus.Succeeded) {
    console.error(`Action failed with message ${result.error.message}`);
    return;
  }
  console.log(`Appointment location: ${result.value}`);
});

setAsync(location, options, callback)

设置约会的位置。

setAsync 方法开始对 Exchange 服务器进行异步调用,以设置约会的位置。 设置约会的位置将覆盖当前位置。

setAsync(location: string, options: Office.AsyncContextOptions, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

location

string

约会的位置。 字符串大小限制为 255 个字符。

options
Office.AsyncContextOptions

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

callback

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

可选。 当该方法完成时, callback 将使用类型 Office.AsyncResult为 . 如果设置位置失败,asyncResult.error 属性将包含一个错误代码。

返回

void

注解

API 集:邮箱 1.1

最低权限级别读取项目

适用的 Outlook 模式:Compose

重要提示:要确保多个位置在 Outlook 中正确解析,请使用分号和空格分隔它们。 例如,“会议室 1;会议室 2“。

错误

  • DataExceedsMaximumSize:位置参数超过 255 个字符。

示例

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

const location = "my office";
Office.context.mailbox.item.location.setAsync(location, (result) => {
  if (result.status !== Office.AsyncResultStatus.Succeeded) {
    console.error(`Action failed with message ${result.error.message}`);
    return;
  }
  console.log(`Successfully set location to ${location}`);
});

setAsync(location, callback)

设置约会的位置。

setAsync 方法开始对 Exchange 服务器进行异步调用,以设置约会的位置。 设置约会的位置将覆盖当前位置。

setAsync(location: string, callback?: (asyncResult: Office.AsyncResult<void>) => void): void;

参数

location

string

约会的位置。 字符串大小限制为 255 个字符。

callback

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

可选。 当该方法完成时, callback 将使用类型 Office.AsyncResult为 . 如果设置位置失败,asyncResult.error 属性将包含一个错误代码。

返回

void

注解

API 集:邮箱 1.1

最低权限级别读取项目

适用的 Outlook 模式:Compose

重要提示:要确保多个位置在 Outlook 中正确解析,请使用分号和空格分隔它们。 例如,“会议室 1;会议室 2“。

错误

  • DataExceedsMaximumSize:位置参数超过 255 个字符。