GetInterface Method (IMessage)

Topic Last Modified: 2006-06-13

Returns the specified dual interface on the object.

Applies To

IMessage Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

Function GetInterface(    ByVal Interface As String) As Object
HRESULT GetInterface
(
        BSTR Interface,
        IDispatch** pVal
);

Parameters

  • Interface
    The name of the interface to obtain.
  • pVal
    Returned reference to the IDispatch Interface of the object.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The GetInterface method is primarily intended as a generic interface navigation aid to scripting languages that do not support such navigation directly. Most Component Object Model (COM) classes that provide implementations of the IMessage interface expose additional dual interfaces that are accessible by scripting languages only through properties on the interface, such as BodyPart and DataSource, or through the GetInterface method. When properties do not exist on the interface to return these interfaces, the GetInterface method must be used.

The list of valid interface names to pass to GetInterface is dependent upon a specific implementation. As a general rule, the name of the desired interface should match the physical name of the interface as it appears in the type library or .idl file. Check the appropriate COM class for a list of exposed dual interfaces.

Examples

The following example in Microsoft® Visual Basic® Scripting Edition (VBScript) demonstrates using GetInterface to return other interfaces on a Message object.

'Dim iMessage
Set iMessage = CreateObject("CDO.Message")
' create an instance...get IMessage (IDispatch) back
Set iDataSource = iMessage.GetInterface("IDataSource")
' get IDataSource on the Message Object
Set iBodyPart = iMessage.GetInterface("IBodyPart")
' get IBodyPart on the Message Object


var iMsg = new ActiveXObject("CDO.Message");
var iDsrc = iMsg.GetInterface("IDataSource");
var iBp   = iMsg.GetInterface("IBodyPart");