IUccPresenceContactCardInstance.RemovePhone 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 a phone entry from the contact card.
Namespace: Microsoft.Office.Interop.UccApi
Assembly: Microsoft.Office.Interop.UccApi (in microsoft.office.interop.uccapi.dll)
Syntax
'Declaration
Sub RemovePhone ( _
pPhone As UccPresenceContactCardPhone _
)
void RemovePhone (
UccPresenceContactCardPhone pPhone
)
void RemovePhone (
UccPresenceContactCardPhone^ pPhone
)
void RemovePhone (
UccPresenceContactCardPhone pPhone
)
function RemovePhone (
pPhone : UccPresenceContactCardPhone
)
Parameters
- pPhone
A value of the IUccPresenceContactCardPhone* (UccPresenceContactCardPhone, for a .NET application) type.
Remarks
This method removes the phone represented by the pPhone
paramter from the phone collection. A phone collection can hold a single phone of a given UCC_CONTACT_CARD_PHONE_TYPE type. If an application method is passed an enumeration of the contact card type, it can get the corresponding IUccPresenceContactCardPhone instance out of the collection and pass that obtained instance to the RemovePhone method.
Win32 COM/C++ Syntax
HRESULT RemovePhone
(
IUccPresenceContactCardPhone* pPhone
);
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 phone to remove from a contact card phone collection. Using the passed string, the method finds the corresponding phone instance in the collection. Finally, the phone 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 a phone from a presence contact card instance phone collection
/// </summary>
/// <param name="pPhoneType">string phone type</param>
/// <returns>boolean true or false indicating success or otherwise</returns>
public Boolean RemovePhoneObject(string pPhoneType)
{
Boolean returnValue = false;
UccPresenceContactCardPhone phoneToRemove = null;
switch (pPhoneType.ToLower())
{
case "home":
phoneToRemove = this.GetPhoneObject(
UCC_CONTACT_CARD_PHONE_TYPE.UCCCCPT_HOME);
break;
case "work":
phoneToRemove = this.GetPhoneObject(
UCC_CONTACT_CARD_PHONE_TYPE.UCCCCPT_WORK);
break;
case "mobile":
phoneToRemove = this.GetPhoneObject(
UCC_CONTACT_CARD_PHONE_TYPE.UCCCCPT_WORK);
break;
case "fax":
phoneToRemove = this.GetPhoneObject(
UCC_CONTACT_CARD_PHONE_TYPE.UCCCCPT_FAX);
break;
case "other":
phoneToRemove = this.GetPhoneObject(
UCC_CONTACT_CARD_PHONE_TYPE.UCCCCPT_OTHER);
break;
case "unknown":
phoneToRemove = this.GetPhoneObject(
UCC_CONTACT_CARD_PHONE_TYPE.UCCCCPT_UNKNOWN);
break;
}
try
{
this._ContactCard.RemovePhone(phoneToRemove);
returnValue = true;
}
catch
{
}
return returnValue;
}
/// <summary>
/// Iterate on a phone collection to find a phone object matching the
/// passed phone type
/// </summary>
/// <param name="phoneType">UCC_CONTACT_CARD_PHONE_TYPE type to find</param>
/// <returns>mathing UccPresenceContactCardPhone</returns>
public UccPresenceContactCardPhone GetPhoneObject(UCC_CONTACT_CARD_PHONE_TYPE phoneType)
{
UccPresenceContactCardPhone returnValue = null;
foreach (UccPresenceContactCardPhone phone in this._ContactCard.Phones)
{
if (phone.Type == phoneType)
{
returnValue = phone;
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