Office.Contact interface

表示有关联系人 (的详细信息,类似于从项目正文中提取的物理联系人或业务卡) 。 仅限阅读模式。

从电子邮件或约会的正文中提取的联系人列表在当前项目的 或 getEntitiesByType 方法返回getEntitiesEntities 对象的 属性中contacts返回。

注解

最低权限级别受限

适用的 Outlook 模式:读取

重要提示:基于实体的上下文 Outlook 加载项将在 2024 年第 2 季度停用。 停用此功能的工作将于 5 月开始,并持续到 6 月底。 6 月之后,上下文加载项将无法再检测邮件项目中的实体以对其执行任务。 以下 API 也将停用。

  • Office.context.mailbox.item.getEntities - Office.context.mailbox.item.getEntitiesByType - Office.context.mailbox.item.getFilteredEntitiesByName - Office.context.mailbox.item.getSelectedEntities

为了帮助最大程度地减少潜在的中断,在基于实体的上下文加载项停用后,仍支持以下内容。

  • 正在开发由联机会议加载项激活的 “加入 会议”按钮的替代实现。 结束对基于实体的上下文加载项的支持后,联机会议加载项将自动转换为替代实现,以激活“ 加入会议 ”按钮。

  • 基于实体的上下文加载项停用后,将继续支持正则表达式规则。 建议更新上下文加载项,以使用正则表达式规则作为替代解决方案。 有关如何实现这些规则的指南,请参阅 使用正则表达式激活规则显示 Outlook 加载项

有关详细信息,请参阅 基于实体的上下文 Outlook 加载项的停用。

示例

const item = Office.context.mailbox.item;
// Get an array of strings that represent contacts in the current item's body.
const contacts = item.getEntitiesByType(Office.MailboxEnums.EntityType.Contact);
console.log("There are " + contacts.length + " contacts.")
contacts.forEach(function (contact) {
    console.log("Person name: " + JSON.stringify(contact.personName));
    console.log("Business name: " + JSON.stringify(contact.businessName));
    console.log("Addresses: " + JSON.stringify(contact.addresses));
    console.log("Phone numbers: " + JSON.stringify(contact.phoneNumbers));
    console.log("Email addresses: " + JSON.stringify(contact.emailAddresses));
    console.log("Urls: " + JSON.stringify(contact.urls));
});

/* Example email that includes contact details of sender, John Smith:
Hi there,
I have received the package.

Thanks.
John Smith
Account Manager
Contoso Corporation
1 Contoso Way, Redmond, WA 98052
john.smith@contoso.com
111-111-1111
https://contoso.com/john.smith
*/

属性

addresses

包含与联系人关联的邮件和街道地址的字符串数组。 可为 NULL。

businessName

包含与联系人关联的企业名称的字符串。 可为 NULL。

emailAddresses

包含与联系人关联的 SMTP 电子邮件地址的字符串数组。 可为 NULL。

personName

包含与联系人关联的人员姓名的字符串。 可为 NULL。

phoneNumbers

包含与联系人关联的每个电话号码的 PhoneNumber 对象的数组。 可为 NULL。

urls

包含与联系人关联的 Internet URL 的字符串数组。 可为 NULL。

属性详细信息

addresses

包含与联系人关联的邮件和街道地址的字符串数组。 可为 NULL。

addresses: string[];

属性值

string[]

businessName

包含与联系人关联的企业名称的字符串。 可为 NULL。

businessName: string;

属性值

string

emailAddresses

包含与联系人关联的 SMTP 电子邮件地址的字符串数组。 可为 NULL。

emailAddresses: string[];

属性值

string[]

personName

包含与联系人关联的人员姓名的字符串。 可为 NULL。

personName: string;

属性值

string

phoneNumbers

包含与联系人关联的每个电话号码的 PhoneNumber 对象的数组。 可为 NULL。

phoneNumbers: PhoneNumber[];

属性值

urls

包含与联系人关联的 Internet URL 的字符串数组。 可为 NULL。

urls: string[];

属性值

string[]