Office.Contact interface

Represents the details about a contact (similar to what's on a physical contact or business card) extracted from the item's body. Read mode only.

The list of contacts extracted from the body of an email message or appointment is returned in the contacts property of the Entities object returned by the getEntities or getEntitiesByType method of the current item.

Remarks

Minimum permission level: restricted

Applicable Outlook mode: Read

Important: Entity-based contextual Outlook add-ins will be retired in Q2 of 2024. The work to retire this feature will start in May and continue until the end of June. After June, contextual add-ins will no longer be able to detect entities in mail items to perform tasks on them. The following APIs will also be retired.

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

To help minimize potential disruptions, the following will still be supported after entity-based contextual add-ins are retired.

  • An alternative implementation of the Join Meeting button, which is activated by online meeting add-ins, is being developed. Once support for entity-based contextual add-ins ends, online meeting add-ins will automatically transition to the alternative implementation to activate the Join Meeting button.

  • Regular expression rules will continue to be supported after entity-based contextual add-ins are retired. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Use regular expression activation rules to show an Outlook add-in.

For more information, see Retirement of entity-based contextual Outlook add-ins.

Examples

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
*/

Properties

addresses

An array of strings containing the mailing and street addresses associated with the contact. Nullable.

businessName

A string containing the name of the business associated with the contact. Nullable.

emailAddresses

An array of strings containing the SMTP email addresses associated with the contact. Nullable.

personName

A string containing the name of the person associated with the contact. Nullable.

phoneNumbers

An array containing a PhoneNumber object for each phone number associated with the contact. Nullable.

urls

An array of strings containing the Internet URLs associated with the contact. Nullable.

Property Details

addresses

An array of strings containing the mailing and street addresses associated with the contact. Nullable.

addresses: string[];

Property Value

string[]

businessName

A string containing the name of the business associated with the contact. Nullable.

businessName: string;

Property Value

string

emailAddresses

An array of strings containing the SMTP email addresses associated with the contact. Nullable.

emailAddresses: string[];

Property Value

string[]

personName

A string containing the name of the person associated with the contact. Nullable.

personName: string;

Property Value

string

phoneNumbers

An array containing a PhoneNumber object for each phone number associated with the contact. Nullable.

phoneNumbers: PhoneNumber[];

Property Value

urls

An array of strings containing the Internet URLs associated with the contact. Nullable.

urls: string[];

Property Value

string[]