Office.Diagnostics interface

将诊断信息提供给 Outlook 外接程序。

注解

[ API set: Mailbox 1.1 ]

最低权限级别读取项

适用的 Outlook 模式:撰写或阅读

从邮箱要求集 1.5 开始,还可以使用 Office.context.诊断 属性获取类似信息。

示例

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

// This function gets a mailbox's diagnostic information, such as Outlook client and version, and logs it to the console.
const diagnostics = Office.context.mailbox.diagnostics;
console.log(`Client application: ${diagnostics.hostName}`);
console.log(`Client version: ${diagnostics.hostVersion}`);

switch (diagnostics.OWAView) {
  case undefined:
    console.log("Current view (Outlook on the web only): Not applicable. An Outlook desktop client is in use.");
    break;
  case Office.MailboxEnums.OWAView.OneColumnNarrow:
    console.log("Current view (Outlook on the web only): Viewed from an older generation mobile phone");
    break;
  case Office.MailboxEnums.OWAView.OneColumn:
    console.log("Current view (Outlook on the web only): Viewed from a newer generation mobile phone");
    break;
  case Office.MailboxEnums.OWAView.TwoColumns:
    console.log("Current view (Outlook on the web only): Viewed from a tablet");
    break;
  case Office.MailboxEnums.OWAView.ThreeColumns:
    console.log("Current view (Outlook on the web only): Viewed from a desktop computer");
    break;
}

属性

hostName

获取表示 Outlook 客户端类型的字符串。

字符串可以是以下值之一:OutlooknewOutlookWindowsOutlookWebAppOutlookIOS或 。OutlookAndroid

hostVersion

获取表示 Outlook 客户端或Exchange Server (版本(例如“15.0.468.0”) )的字符串。

如果邮件加载项在 Outlook 中的桌面或移动客户端中运行,则 hostVersion 属性将返回 Outlook 客户端的版本。 在 Outlook 网页版 中, 属性返回Exchange Server的版本。

OWAView

获取表示Outlook 网页版的当前视图的字符串。

返回的字符串可以是以下值之一: OneColumnTwoColumnsThreeColumns

如果未Outlook 网页版应用程序,则访问此属性会导致未定义。

Outlook 网页版有三个视图,对应于屏幕和窗口的宽度以及可显示的列数:

  • OneColumn,在屏幕较窄时显示。 Outlook 网页版在智能手机的整个屏幕上使用此单列布局。

  • TwoColumns,在屏幕较宽时显示。 Outlook 网页版在大多数平板电脑上使用此视图。

  • ThreeColumns,在屏幕较宽时显示。 例如,Outlook 网页版在台式计算机上的全屏窗口中使用此视图。

属性详细信息

hostName

获取表示 Outlook 客户端类型的字符串。

字符串可以是以下值之一:OutlooknewOutlookWindowsOutlookWebAppOutlookIOS或 。OutlookAndroid

hostName: string;

属性值

string

注解

[ API set: Mailbox 1.1 ]

最低权限级别读取项

适用的 Outlook 模式:撰写或阅读

重要提示:为 Outlook Windows 和 Mac 上的 Outlook 桌面客户端返回该值。 newOutlookWindows 为当前处于预览状态 的新 Outlook on Windows 桌面客户端 返回 。

hostVersion

获取表示 Outlook 客户端或Exchange Server (版本(例如“15.0.468.0”) )的字符串。

如果邮件加载项在 Outlook 中的桌面或移动客户端中运行,则 hostVersion 属性将返回 Outlook 客户端的版本。 在 Outlook 网页版 中, 属性返回Exchange Server的版本。

hostVersion: string;

属性值

string

注解

[ API set: Mailbox 1.1 ]

最低权限级别读取项

适用的 Outlook 模式:撰写或阅读

OWAView

获取表示Outlook 网页版的当前视图的字符串。

返回的字符串可以是以下值之一: OneColumnTwoColumnsThreeColumns

如果未Outlook 网页版应用程序,则访问此属性会导致未定义。

Outlook 网页版有三个视图,对应于屏幕和窗口的宽度以及可显示的列数:

  • OneColumn,在屏幕较窄时显示。 Outlook 网页版在智能手机的整个屏幕上使用此单列布局。

  • TwoColumns,在屏幕较宽时显示。 Outlook 网页版在大多数平板电脑上使用此视图。

  • ThreeColumns,在屏幕较宽时显示。 例如,Outlook 网页版在台式计算机上的全屏窗口中使用此视图。

OWAView: MailboxEnums.OWAView | "OneColumn" | "TwoColumns" | "ThreeColumns";

属性值

Office.MailboxEnums.OWAView | "OneColumn" | "TwoColumns" | "ThreeColumns"

注解

[ API set: Mailbox 1.1 ]

最低权限级别读取项

适用的 Outlook 模式:撰写或阅读