Office.PhoneNumber interface
Represents a phone number identified in an item. Read mode only.
An array of PhoneNumber
objects containing the phone numbers found in an email message is returned in the phoneNumbers
property of the Entities
object that's returned when you call the getEntities
method on the selected item.
Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. 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 Contextual Outlook add-ins.
Remarks
Minimum permission level: read item
Applicable Outlook mode: Read
Examples
const item = Office.context.mailbox.item;
// Get an array of strings that represent phone numbers in the current item's body.
const phoneNumbers = item.getEntitiesByType(Office.MailboxEnums.EntityType.PhoneNumber);
console.log("There are " + phoneNumbers.length + " phone numbers.")
phoneNumbers.forEach(function (phoneNumber) {
console.log("Phone number: " + JSON.stringify(phoneNumber.phoneString));
console.log("Type: " + JSON.stringify(phoneNumber.type));
console.log("Source text: " + JSON.stringify(phoneNumber.originalPhoneString));
});
Properties
original |
Gets the text that was identified in an item as a phone number. Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. 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 Contextual Outlook add-ins. |
phone |
Gets a string containing a phone number. This string contains only the digits of the telephone number and excludes characters like parentheses and hyphens, if they exist in the original item. Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. 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 Contextual Outlook add-ins. |
type | Gets a string that identifies the type of phone number: Home, Work, Mobile, Unspecified. Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. 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 Contextual Outlook add-ins. |
Property Details
originalPhoneString
Gets the text that was identified in an item as a phone number.
Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. 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 Contextual Outlook add-ins.
originalPhoneString: string;
Property Value
string
phoneString
Gets a string containing a phone number. This string contains only the digits of the telephone number and excludes characters like parentheses and hyphens, if they exist in the original item.
Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. 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 Contextual Outlook add-ins.
phoneString: string;
Property Value
string
type
Gets a string that identifies the type of phone number: Home, Work, Mobile, Unspecified.
Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. 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 Contextual Outlook add-ins.
type: string;
Property Value
string
Office Add-ins