Platform SDK: Exchange 2000 Server

Open Method

[This is preliminary documentation and subject to change.]

Binds to and opens data from the existing item specified by URL.

[Visual Basic,VBScript]
Sub Open(
  ByVal SourceURL as String,
  ByVal ActiveConnection as Object,
  [ByVal Mode as ConnectModeEnum],
  [ByVal CreateOptions as RecordCreateOptionsEnum],
  [ByVal Options as RecordOpenOptionsEnum],
  [ByVal UserName as String],
  [ByVal Password as String]
)
[C++]
HRESULT Open(BSTR SourceURL,
  IDispatch* ActiveConnection = 0,
  ConnectModeEnum Mode,
  RecordCreateOptionsEnum CreateOptions,
  RecordOpenOptionsEnum Options,
  BSTR UserName,
  BSTR Password
);
[IDL]
HRESULT Open(
  [in] BSTR SourceURL,
  [in, defaultvalue(0)] IDispatch* ActiveConnection,
  [in, optional] ConnectModeEnum Mode,
  [in, optional] RecordCreateOptionsEnum CreateOptions,
  [in, optional] RecordOpenOptionsEnum Options,
  [in, optional] BSTR UserName,
  [in, optional] BSTR Password
);
SourceURL
Specifies the URL of the existing item to open. New items cannot be created using the Open method. Use SaveTo or SaveToContainer.
ActiveConnection
Specifies the connection to use when opening. This is a reference to an ADO Connection object. A new Connection object (session) is implicitly created if none is specified.
Mode
ADO-defined access mode enumeration. The specified value is always ORed with adModeRead (1). This means that at least read access is requested when opening an item, not that only read access is requested.
CreateOptions
Must be adFailIfNotExists. New items cannot be created using the Open method.
Options
This specifies options flag opening the source. The only supported open option is adOpenAsynch. Your setting is always ORed with adOpenSource.
UserName
Used to pass a user name if needed for authentication.
Password
Used to pass a password if needed for authentication.

Remarks

The specified URL must identify a valid URL namespace that the OLE DB 2.5 root binder can resolve to a registered provider binder. Once resolved, the URL must conform to that provider binder's URL semantics.

The Open method has an identical signature to the Open method defined by ADO interfaces such as the _Record, _Recordset, and _Stream interfaces. The IDataSource.Open method, unlike the _Record.Open or _Stream.Open, cannot be used to create new items. Therefore, the CreateOption parameter must always be set to adFailIfNotExists. The other enumerated values and their semantic definitions are defined as part of the ADO type library and documentation. Consult the Microsoft® ActiveX® Data Objects (ADO) Version 2.5 documentation for a list of valid enumeration values and their intended purpose. Use of various enumerated values and their intended meaning is specific to a particular OLE DB 2.5 provider.

Restrictions on what types of data can be opened and how that data is handled by an implementation of the IDataSource interface is not part of this definition. Consult the appropriate COM class reference for further information.

Example

[Visual Basic]
    Dim iFldr As New Folder
    Dim iDsrc As CDO.IDataSource
    Set iDsrc = iFldr
    
    ' Open private root folder:
    ' e.g. URL1 = "file://./backofficestorage/microsoft.com/MBX2/useralias/"
    iDsrc.Open URL1, , adModeReadWrite
    
    Dim Conn As ADODB.Connection
    Set Conn = iDsrc.ActiveConnection
    
    Dim iMsg As New CDO.Message
    Set iDsrc = iMsg
    
    iDsrc.Open "MySavedItems/item8.eml", _
                Conn, _
                adModeReadWrite

[C++,IDL]
/* Assume these headers:
 *
 * #import <msado15.dll> no_namespace
 * #import <cdoex.dll> no_namespace
 * #include <iostream.h>
 */

   IDataSource* pDsrc   = NULL;
   HRESULT hr = CoCreateInstance(__uuidof(Item),
                        NULL,
                        CLSCTX_INPROC_SERVER,
                        __uuidof(IDataSource),
                        reinterpret_cast<void**>(&pDsrc));


   // for passing optional variants, we may need this
   _variant_t varOpt(DISP_E_PARAMNOTFOUND,VT_ERROR);
   
   /* 
   * Bind to web store root folder (private/messages)
   *  e.g. URL1 below is something like 
   * "file://./backofficestorage/microsoft.com/MBX/username/"
   * or "http://servername/exchange/username/"
    */

   hr=pDsrc->raw_Open( 
      url,
      NULL,
      adModeRead,
      adFailIfNotExists,
      adOpenSource,
      NULL,
      NULL
      );

   if(FAILED(hr)) {
      cerr << "Error opening " << _bstr_t(url) << endl;
      pDsrc->Release();
      return hr;
   }


   return pDsrc->QueryInterface(__uuidof(IItem),reinterpret_cast<void**>(ppItem));
}
[VBScript]
    Const adModeRead        = 1
    Const adModeReadWrite   = 3
    Const adCreateOverwrite = 67108864

    Dim iFldr
    Set iFldr = CreateObject("CDO.Folder")
    Dim iDsrc
    Set iDsrc = iFldr
    
    ' Open private root folder:
    ' e.g. URL1 = "file://./backofficestorage/microsoft.com/MBX2/useralias/"
    iDsrc.Open URL1, , adModeReadWrite
    
    Dim Conn As ADODB.Connection
    Set Conn = iDsrc.ActiveConnection
    
    Dim iMsg As New CDO.Message
    Set iDsrc = iMsg
    
    iDsrc.Open "MySavedItems/item8.eml", _
                Conn, _
                adModeReadWrite