Contact class
TOC
Collapse the table of content
Expand the table of content

Contact class

Represents a contact.

Syntax


var contact = new Windows.ApplicationModel.Contacts.Contact();

Members

The Contact class has these types of members:

Constructors

The Contact class has these constructors.

ConstructorDescription
Contact Creates a new instance of the Contact class.

 

Properties

The Contact class has these properties.

PropertyAccess typeDescription

Addresses

Read-only

Gets the contact addresses for a contact.

AggregateId

Read-only

If this is a raw contact that is part of an aggregate contact, then this property identifies the parent aggregate.

ConnectedServiceAccounts

Read-only

Gets the connected service accounts for a contact.

ContactListId

Read-only

Gets a string that identifies the ContactList to which this contact is a member.

DataSuppliers

Read-only

Gets the data suppliers for a contact. The maximum string length for each data supplier is 50 characters.

DisplayName

Read-only

Gets the display name for a contact. You can only access this property from a UI thread.

DisplayNameOverride

Read/write

Gets or sets the display that was manually entered by the user.

DisplayPictureUserUpdateTime

Read/write

Gets or sets the last time the user updated their display picture.

Emails

Read-only

Gets the email addresses for a contact.

Fields

Read-only

Fields may be altered or unavailable for releases after Windows 8.1. Instead, use Phones, Emails, Addresses, or ConnectedServiceAccounts. Sets the fields that contain information about a contact.

FirstName

Read/write

Gets and sets the first name for a contact. The maximum string length for the first name is 64 characters.

FullName

Read-only

Gets the full name of the Contact.

HonorificNamePrefix

Read/write

Gets and sets the honorific prefix for the name for a contact. The maximum string length for the honorific prefix is 32 characters.

HonorificNameSuffix

Read/write

Gets and sets the honorific suffix for the name for a contact. The maximum string length for the honorific suffix is 32 characters.

Id

Read/write

Gets and sets the identifier for a contact. The maximum string length for the identifier is 256 characters.

ImportantDates

Read-only

Gets the important dates for a contact.

IsAggregate

Read-only

Gets a Boolean value indicating of this is an aggregate Contact.

IsDisplayPictureManuallySet

Read-only

Gets a Boolean value indicating if the user manually set the picture for the Contact.

IsMe

Read-only

Gets a Boolean value indicating if this Contact represents the user logged into the device.

JobInfo

Read-only

Gets the job info items for a contact.

LargeDisplayPicture

Read-only

Gets a large version of the display picture for the Contact.

LastName

Read/write

Gets and sets the last name for a contact. The maximum string length for the last name is 64 characters.

MiddleName

Read/write

Gets and sets the middle name for a contact. The maximum string length for the middle name is 64 characters.

Name

Read/write

Name may be altered or unavailable for releases after Windows 8.1. Instead, use FirstName.Sets and gets the name of the contact.

Nickname

Read/write

Gets or sets the nickname for the Contact.

Notes

Read/write

Gets and sets notes for a contact. The maximum string length for notes is 4096 characters.

Phones

Read-only

Gets info about the phones for a contact.

ProviderProperties

Read-only

Gets the property set object for the contact.

RemoteId

Read/write

Gets or sets an ID that can be used by a service provider to access the Contact in their remote system.

RingToneToken

Read/write

Gets or puts the path to the ringtone file for the Contact.

SignificantOthers

Read-only

Gets the significant others for a contact.

SmallDisplayPicture

Read-only

Gets a small version of the display picture for the Contact.

SortName

Read-only

Gets the name used to sort the contact.

SourceDisplayPicture

Read/write

Gets or sets the display picture for the Contact in its original size.

TextToneToken

Read/write

Gets or puts the path to the audio file to play when an SMS/MMS message is received from the Contact.

Thumbnail

Read/write

Gets or sets a thumbnail image that represents this contact.

Websites

Read-only

Gets the Web sites for a contact.

YomiDisplayName

Read-only

Gets the Yomi (phonetic Japanese equivalent) display name for a contact.

YomiFamilyName

Read/write

Gets the Yomi (phonetic Japanese equivalent) family name for a contact. The maximum string length for the Yomi family name is 120 characters.

YomiGivenName

Read/write

Gets the Yomi (phonetic Japanese equivalent) given name for a contact. The maximum string length for the Yomi given name is 120 characters.

 

Remarks

No matter how you store contact information in your app, you must be able to put that information into a Contact object. This way, other apps that allow users to select contacts can use your app and process the contact information it provides.

For info about how to manage contacts, see Managing contact cards (XAML) and Managing contact cards (HTML).

Examples

This code shows how your app can take an app-specific contact object and use it to create a Contact object. First, here's an example of an object that contains contact information.


var sampleContacts = [
    {
        firstName: "Kim",
        lastName: "Abercrombie",
        image: "KimAbercrombie.jpg",
        personalEmail: "kim@contoso.com",
        homePhone: "921 555-0187",
        address: {
            full: "123 Main St, Redmond WA, 23456",
            street: "123 Main St",
            city: "Redmond",
            state: "WA",
            zipCode: "23456"
        },
        id: "49b0652e-8f39-48c5-853b-e5e94e6b8a11"
    }
];


This function creates the contact, which supports a number of fields:


function createContactForBasket(sampleContact) {

    // Transfer contact data to a Contact object
    var contact = new Windows.ApplicationModel.Contacts.Contact();
    contact.firstName = sampleContact.firstName;
    contact.lastName = sampleContact.lastName;
    contact.id = sampleContact.id;

    // Add the personal email address to the Contact object’s emails vector
    var personalEmail = new Windows.ApplicationModel.Contacts.ContactEmail();
    personalEmail.address = sampleContact.personalEmail;
    personalEmail.kind = Windows.ApplicationModel.Contacts.ContactEmailKind.personal;
    contact.emails.append(personalEmail);

    // Adds the home phone number to the Contact object’s phones vector
    var homePhone = new Windows.ApplicationModel.Contacts.ContactPhone();
    homePhone.number = sampleContact.homePhone;
    homePhone.kind = Windows.ApplicationModel.Contacts.ContactPhoneKind.home;
    contact.phones.append(homePhone);

    // Adds the address to the Contact object’s addresses vector
    var homeAddress = new Windows.ApplicationModel.Contacts.ContactAddress();
    homeAddress.streetAddress = sampleContact.address.street;
    homeAddress.locality = sampleContact.address.city;
    homeAddress.region = sampleContact.address.state;
    homeAddress.postalCode = sampleContact.address.zipCode;
    homeAddress.kind = Windows.ApplicationModel.Contacts.ContactAddressKind.home;
    contact.addresses.append(homeAddress);

    // Sets the thumbnail for the contact from path
    Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(sampleContact.image).then(
          function (imageFile) {
                 var streamReference = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile);
                 contact.thumbnail = randomAccessStreamReference;
          });

    return contact;
}


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.ApplicationModel.Contacts
Windows::ApplicationModel::Contacts [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.Contacts
Windows::ApplicationModel::Contacts [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Agile)]
[Muse()]
[Version(0x06020000)]

See also

Object
Contact manager API sample
Contact Picker app sample
Handling Contact Actions sample
Contact cards sample (Windows 10)

 

 

Show:
© 2016 Microsoft