Question

I am trying to get access to all the endpoints that a particular contact might have so that I can display them, and the only place I have been able to find such a collection in the documentation is in the ContactEndpointCollection. However, despite all my searching I cant seem to find how you can get this collection from a particular Contact.

So my question is this: given a Contact, how can I get their ContactEndpointCollection?

Was it helpful?

Solution

You need to use the GetContactInformation method to get the contact endpoints.

Contact c;
List<object> endpoints = c.GetContactInformation(ContactInformationType.ContactEndpoints) as List<object>;
foreach(object o in endpoints)
{
    ContactEndpoint ce = o as ContactEndpoint;
    // Stuff
}

This returns an object, which you will need to cast to a list of objects. Then you can iterate through that list, casting each element as a ContactEndpoint. I don't know how to avoid the double casting, I am sure there is a way but this is a workaround.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top