Known​Contact​Field Known​Contact​Field Known​Contact​Field Class

Definition

Note

KnownContactField may be altered or unavailable for releases after Windows 8.1. Instead, use ContactAddress, ContactPhone, ContactConnectedServiceAccount, or ContactEmail.

A static class that contains the names of contact fields for storing commonly requested information like email address and phone numbers.

public static class KnownContactFieldpublic static class KnownContactFieldPublic Static Class KnownContactField
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The KnownContactField class is designed for use as a parameter with the DesiredFields property of the ContactPicker. It allows apps to clearly specify what fields to retrieve from contact providers.

Examples

This example demonstrates how to use the KnownContactField class.

function selectKnownFields() {
    var picker = Windows.ApplicationModel.Contacts.ContactPicker();
    picker.commitButtonText = "Select";
    picker.selectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.fields;
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.email);
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.instantMessage);
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.location);
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.phoneNumber);
    picker.pickSingleContactAsync().then(function (contact) {
        var contactElement = document.createElement("div");
        var contactData = contact.name + ", ";
        contactData += contact.emails[0].value + ", ";
        contactData += contact.instantMessages[0].value + ", ";
        contactData += contact.locations[0].value + ", ";
        contactData += contact.phoneNumbers[0].value;
        contactElement.innerText = contactData;
        document.body.appendChild(contactElement);
    });
}

Properties

Email Email Email

Note

KnownContactField may be altered or unavailable for releases after Windows 8.1. Instead, use ContactAddress, ContactPhone, ContactConnectedServiceAccount, or ContactEmail.

Contains the name of the field used for email addresses.

public static PlatForm::String Email { get; }public static string Email { get; }Public Static ReadOnly Property Email As string
Value
string string string

The name of the field.

Attributes

Remarks

Use this property with the ContactPicker.DesiredFields property to specify that you want to get the email addresses of a contact.

Examples

This code demonstrates how to get an email address of a contact.

function selectKnownFields() {
    var picker = Windows.ApplicationModel.Contacts.ContactPicker();
    picker.commitButtonText = "Select";
    picker.selectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.fields;
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.email);
    picker.pickSingleContactAsync().then(function (contact) {
        var contactElement = document.createElement("div");
        var contactData = contact.name + ", ";
        contactData += contact.emails[0].value + ", ";
        contactElement.innerText = contactData;
        document.body.appendChild(contactElement);
    });
}

InstantMessage InstantMessage InstantMessage

Note

KnownContactField may be altered or unavailable for releases after Windows 8.1. Instead, use ContactAddress, ContactPhone, ContactConnectedServiceAccount, or ContactEmail.

Contains the name of the field used for instant messaging accounts.

public static PlatForm::String InstantMessage { get; }public static string InstantMessage { get; }Public Static ReadOnly Property InstantMessage As string
Value
string string string

The name of the field.

Attributes

Remarks

Use this property with the ContactPicker.DesiredFields property to specify that you want to get the instant messaging names that a contact uses.

Examples

This code demonstrates how to get a contact's instant messaging information.

function getInstantMessageInfo() {
    var picker = Windows.ApplicationModel.Contacts.ContactPicker();
    picker.commitButtonText = "Select";
    picker.selectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.fields;
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.instantMessage);
    picker.pickSingleContactAsync().then(function (contact) {
        var contactElement = document.createElement("div");
        var contactData = contact.name + "<br/>";
        contactData += contact.instantMessages[0].displayText + "<br/>";
        contactData += contact.instantMessages[0].launchUri + "<br/>";
        contactData += contact.instantMessages[0].service + "<br/>";
        contactData += contact.instantMessages[0].userName + "<br/>";
        contactData += contact.instantMessages[0].category + "<br/>";
        contactData += contact.instantMessages[0].type;
        contactElement.innerHTML = contactData;
        document.body.appendChild(contactElement);
    });
}

Location Location Location

Note

KnownContactField may be altered or unavailable for releases after Windows 8.1. Instead, use ContactAddress, ContactPhone, ContactConnectedServiceAccount, or ContactEmail.

Contains the name of the field used for the contact's location.

public static PlatForm::String Location { get; }public static string Location { get; }Public Static ReadOnly Property Location As string
Value
string string string

The name of the field.

Attributes

Remarks

Use this property with the ContactPicker.DesiredFields property to specify that you want to get the location of a contact.

Examples

This code demonstrates how to get the location of a contact.

function getLocation() {
    var picker = Windows.ApplicationModel.Contacts.ContactPicker();
    picker.commitButtonText = "Select";
    picker.selectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.fields;
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.location);
    picker.pickSingleContactAsync().then(function (contact) {
        var contactElement = document.createElement("div");
        var contactData = contact.name + "<br/>";
        contactData += contact.locations[0].city + "<br/>";
        contactData += contact.locations[0].country + "<br/>";
        contactData += contact.locations[0].postalcode + "<br/>";
        contactData += contact.locations[0].region = "<br/>";
        contactData += contact.locations[0].street + "<br/>";
        contactData += contact.instantMessages[0].category + "<br/>";
        contactData += contact.instantMessages[0].type;
        contactElement.innerHTML = contactData;
        document.body.appendChild(contactElement);
    });
}

PhoneNumber PhoneNumber PhoneNumber

Note

KnownContactField may be altered or unavailable for releases after Windows 8.1. Instead, use ContactAddress, ContactPhone, ContactConnectedServiceAccount, or ContactEmail.

Contains the name of the field used for phone numbers.

public static PlatForm::String PhoneNumber { get; }public static string PhoneNumber { get; }Public Static ReadOnly Property PhoneNumber As string
Value
string string string

The name of the field.

Attributes

Remarks

Use this property with the ContactPicker.DesiredFields property to specify that you want to get the phone numbers of a contact.

Examples

This code demonstrates how to get a phone number of a contact.

function selectKnownFields() {
    var picker = Windows.ApplicationModel.Contacts.ContactPicker();
    picker.commitButtonText = "Select";
    picker.selectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.fields;
    picker.desiredFields.append(Windows.ApplicationModel.Contacts.KnownContactField.phoneNumber);
    picker.pickSingleContactAsync().then(function (contact) {
        var contactElement = document.createElement("div");
        var contactData = contact.name + ", ";
        contactData += contact.phoneNumbers[0].value + ", ";
        contactElement.innerText = contactData;
        document.body.appendChild(contactElement);
    });
}

Methods

ConvertNameToType(String) ConvertNameToType(String) ConvertNameToType(String)

Note

KnownContactField may be altered or unavailable for releases after Windows 8.1. Instead, use ContactAddress, ContactPhone, ContactConnectedServiceAccount, or ContactEmail.

Converts a string representing the name of a field to its corresponding type.

public static ContactFieldType ConvertNameToType(String name)public static ContactFieldType ConvertNameToType(String name)Public Static Function ConvertNameToType(name As String) As ContactFieldType
Parameters
name
System.String System.String System.String

The name of the field.

Returns
Attributes

ConvertTypeToName(ContactFieldType) ConvertTypeToName(ContactFieldType) ConvertTypeToName(ContactFieldType)

Note

KnownContactField may be altered or unavailable for releases after Windows 8.1. Instead, use ContactAddress, ContactPhone, ContactConnectedServiceAccount, or ContactEmail.

Converts the type of a field to its corresponding string name.

public static PlatForm::String ConvertTypeToName(ContactFieldType type)public static string ConvertTypeToName(ContactFieldType type)Public Static Function ConvertTypeToName(type As ContactFieldType) As string
Parameters
Returns
string string string

The name of the field.

Attributes