IUccPresenceContactCardInstance.RemoveAddress Method

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.

Removes an address from this contact card.

Namespace: Microsoft.Office.Interop.UccApi
Assembly: Microsoft.Office.Interop.UccApi (in microsoft.office.interop.uccapi.dll)

Syntax

'Declaration
Sub RemoveAddress ( _
    pAddress As UccPresenceContactCardAddress _
)
void RemoveAddress (
    UccPresenceContactCardAddress pAddress
)
void RemoveAddress (
    UccPresenceContactCardAddress^ pAddress
)
void RemoveAddress (
    UccPresenceContactCardAddress pAddress
)
function RemoveAddress (
    pAddress : UccPresenceContactCardAddress
)

Parameters

Remarks

This method removes the address represented by the pAddress paramter from the address collection. A single address collection can hold a single address of a given UCC_CONTACT_CARD_ADDRESS_TYPE type. If an application method is passed an enumeration of the contact card type, it can get the corresponding IUccPresenceContactCardAddress instance out of the collection and pass that obtained instance to the RemoveAddress method.

Win32 COM/C++ Syntax

HRESULT RemoveAddress
(
   IUccPresenceContactCardAddress* pAddress
);

Note

In a Win32 application, the return value of a method or property is always an HRESULT value indicating the status of the call to the interface member. Any result of the operation is returned as a parameter marked with the [out, retval] attribute. In contrast, in a .NET application the HRESULT value indicating an error condition is returned as a COM exception and the [out, retval] parameter becomes the return value. For the UCC API-defined HRESULT values, see Trace and Handle Errors in Unified Communications Client API.

Example

The following example method accepts a string representing the type of address to remove from a contact card address collection. Using the passed string, the method finds the corresponding address instance in the collection. Finally, the address instance is removed from the collection. The example method is drawn from an application class that wraps an instance of IUccPresenceContactCardInstance (this._ContactCard). An advantage of this method signature is that calling code does not have to include a reference to the Microsoft.Office.Interop.UccApi namespace.

/// <summary>
/// Removes an address from a presence contact card instance address collection
/// </summary>
/// <param name="pAddressType">string address type</param>
/// <returns>boolean true or fals indicating success or otherwise</returns>
public Boolean RemoveAddressObject(string pAddressType)
{
   Boolean returnValue = false;
   UccPresenceContactCardAddress addressToRemove = null;
   switch (pAddressType.ToLower())
   { 
      case "home":
         addressToRemove = this.GetAddressObject(
            UCC_CONTACT_CARD_ADDRESS_TYPE.UCCCCAT_HOME);
         break;
      case "work":
         addressToRemove = this.GetAddressObject(
            UCC_CONTACT_CARD_ADDRESS_TYPE.UCCCCAT_WORK);
         break;
      case "other":
         addressToRemove = this.GetAddressObject(
            UCC_CONTACT_CARD_ADDRESS_TYPE.UCCCCAT_OTHER);
         break;
      case "unknown":
         addressToRemove = this.GetAddressObject(
            UCC_CONTACT_CARD_ADDRESS_TYPE.UCCCCAT_UNKNOWN);
         break;
   }
   try
   {
      this._ContactCard.RemoveAddress(addressToRemove);
      returnValue = true;
   }
   catch 
   {
   }
   return returnValue;
}
/// <summary>
/// Iterate on an address collection to find an address object matching the 
/// passed address type
/// </summary>
/// <param name="phoneType">UCC_CONTACT_CARD_ADDRESS_TYPE type to find</param>
/// <returns>mathing UccPresenceContactCardAddress</returns>
public UccPresenceContactCardAddress GetAddressObject(UCC_CONTACT_CARD_ADDRESS_TYPE addressType)
{
   UccPresenceContactCardAddress returnValue = null;
   foreach (UccPresenceContactCardAddress address in this._ContactCard.Addresses)
   {
      if (address.Type == addressType)
      {
         returnValue = address;
         break;
      }
   }
   return returnValue;
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2000 with Service Pack 4, Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

IUccPresenceContactCardInstance Interface
IUccPresenceContactCardInstance Members
Microsoft.Office.Interop.UccApi Namespace