Contact Contact Contact Contact Contact Class

Definition

Represents a contact.

public : sealed class Contact : IContact, IContact2, IContact3, IContactName
struct winrt::Windows::ApplicationModel::Contacts::Contact : IContact, IContact2, IContact3, IContactName
public sealed class Contact : IContact, IContact2, IContact3, IContactName
Public NotInheritable Class Contact Implements IContact, IContact2, IContact3, IContactName
var contact = new contact();
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
contactsSystem

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"
        }
];
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;
}

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 and Managing contact cards.

Constructors

Contact() Contact() Contact() Contact() Contact()

Creates a new instance of the Contact class.

Properties

Addresses Addresses Addresses Addresses Addresses

Gets the contact addresses for a contact.

AggregateId AggregateId AggregateId AggregateId AggregateId

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

ConnectedServiceAccounts ConnectedServiceAccounts ConnectedServiceAccounts ConnectedServiceAccounts ConnectedServiceAccounts

Gets the connected service accounts for a contact.

ContactListId ContactListId ContactListId ContactListId ContactListId

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

DataSuppliers DataSuppliers DataSuppliers DataSuppliers DataSuppliers

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

DisplayName DisplayName DisplayName DisplayName DisplayName

Gets the display name for a contact.

Note

You can only access this property from a UI thread.

DisplayNameOverride DisplayNameOverride DisplayNameOverride DisplayNameOverride DisplayNameOverride

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

DisplayPictureUserUpdateTime DisplayPictureUserUpdateTime DisplayPictureUserUpdateTime DisplayPictureUserUpdateTime DisplayPictureUserUpdateTime

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

Emails Emails Emails Emails Emails

Gets the email addresses for a contact.

Fields Fields Fields Fields Fields

Note

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 FirstName FirstName FirstName FirstName

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

FullName FullName FullName FullName FullName

Gets the full name of the Contact.

HonorificNamePrefix HonorificNamePrefix HonorificNamePrefix HonorificNamePrefix HonorificNamePrefix

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

HonorificNameSuffix HonorificNameSuffix HonorificNameSuffix HonorificNameSuffix HonorificNameSuffix

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

Id Id Id Id Id

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

Note

The Id property must be set when you call AddContact, ContainsContact, or RemoveContact. If Id isn't set when you call AddContact, your app will fail. If Id isn't set when you call ContainsContact or RemoveContact, your app won't be able to find or remove the contact.

ImportantDates ImportantDates ImportantDates ImportantDates ImportantDates

Gets the important dates for a contact.

IsAggregate IsAggregate IsAggregate IsAggregate IsAggregate

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

IsDisplayPictureManuallySet IsDisplayPictureManuallySet IsDisplayPictureManuallySet IsDisplayPictureManuallySet IsDisplayPictureManuallySet

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

IsMe IsMe IsMe IsMe IsMe

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

JobInfo JobInfo JobInfo JobInfo JobInfo

Gets the job info items for a contact.

LargeDisplayPicture LargeDisplayPicture LargeDisplayPicture LargeDisplayPicture LargeDisplayPicture

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

LastName LastName LastName LastName LastName

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

MiddleName MiddleName MiddleName MiddleName MiddleName

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

Name Name Name Name Name

Note

Name may be altered or unavailable for releases after Windows 8.1. Instead, use FirstName.

Sets and gets the name of the contact.

Nickname Nickname Nickname Nickname Nickname

Gets or sets the nickname for the Contact.

Notes Notes Notes Notes Notes

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

Phones Phones Phones Phones Phones

Gets info about the phones for a contact.

ProviderProperties ProviderProperties ProviderProperties ProviderProperties ProviderProperties

Gets the property set object for the contact. Note: This property is not persisted if set by an application.

RemoteId RemoteId RemoteId RemoteId RemoteId

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

RingToneToken RingToneToken RingToneToken RingToneToken RingToneToken

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

SignificantOthers SignificantOthers SignificantOthers SignificantOthers SignificantOthers

Gets the significant others for a contact.

SmallDisplayPicture SmallDisplayPicture SmallDisplayPicture SmallDisplayPicture SmallDisplayPicture

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

SortName SortName SortName SortName SortName

Gets the name used to sort the contact.

SourceDisplayPicture SourceDisplayPicture SourceDisplayPicture SourceDisplayPicture SourceDisplayPicture

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

TextToneToken TextToneToken TextToneToken TextToneToken TextToneToken

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

Thumbnail Thumbnail Thumbnail Thumbnail Thumbnail

Gets or sets a thumbnail image that represents this contact.

Websites Websites Websites Websites Websites

Gets the Web sites for a contact.

YomiDisplayName YomiDisplayName YomiDisplayName YomiDisplayName YomiDisplayName

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

YomiFamilyName YomiFamilyName YomiFamilyName YomiFamilyName YomiFamilyName

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

YomiGivenName YomiGivenName YomiGivenName YomiGivenName YomiGivenName

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

See also