Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Add a Contact to the Contact List

Add a Contact to the Contact List

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

A Unified Communications Client API application adds a new contact to a user's contact list by publishing a new instance of the contacts category to the server. The application must set the value of the PublicationOperation property on the to-be-published category instance as UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD. If a previously published category instance is being republished with modifications, the operation type must also be UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD. The publication is mostly useful for persisting a user's contact list between the user's logon sessions.

In Unified Communications Client API, a contact is represented by an IUccContact object, which is a strongly typed category instance. The application can create a publishable contact by first calling the CreatePublishableCategoryInstance method, specifying contacts as the value of the string input parameter for the category name. The application can then proceed to set the contact properties (for example, the contact's URI) by casting the IUccCategoryInstance object into the IUccContact type. The contact must be published to the container with Id UCC_SELF_CONTAINER_ID.

Bb804418.note(en-us,office.12).gifNote:
Each new contact added or updated must be published in a dedicated publication object. Only one contact object is allowed per publication.

The following C# code snippet illustrates how to publish a contact to the private container.

partial class ContactManager
{
    /// <summary>
    /// Adds a contact to the contact list by publishing it to the server
    /// </summary>
    /// <param name="contactURI">URI of the contact to be added</param>
    public void addContact(UccUri contactURI)
    {
        try
        {
            //Create a publishable category instance representing the contact to be added
            IUccCategoryInstance cat = publicationManager. CreatePublishableCategoryInstance(
                    "contacts"
                    , UccConstants.UCC_SELF_CONTAINER_ID
                    , 0  //instance mask
                    , UCC_CATEGORY_INSTANCE_EXPIRE_TYPE.UCCCIET_STATIC
                    , 0);

            //Set publication operation type for this category
            cat.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD;
            
            //Cast the category to IUccContact to set the URI of the contact to be added
            IUccContact contact = cat as IUccContact;
            contact.Uri = contactURI;

            IUccPublication pub = publicationManager.CreatePublication();
            UCC_Advise<_IUccPublicationEvent>(pub, this);
            pub.AddPublishableCategoryInstance(cat);
            pub.Publish(null);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft