ContentClass Property (IFolder)

Topic Last Modified: 2006-06-13

The folder's content class.

Applies To

IFolder Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

Property ContentClass As String
HRESULT get_ContentClass(BSTR* pVal);HRESULT put_ContentClass(BSTR Val);

Parameters

  • pVal
    Returns the value of the ContentClass property as a reference to a BSTR.
  • Val
    Sets the value of the ContentClass property to the value of the BSTR.

Remarks

The ContentClass property is used to indicate the intent or purpose of the folder. For example, a user's Inbox has a content class of "urn:content-classes:mailfolder".

The content class is not the same as the PR_CONTAINER_CLASS MAPI property.

Examples


' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library

' Note: It is recommended that all input parameters be validated before being used.
Function CreateFolder(Url As String, _
                       ContentClass As String, _
                       Description As String)
  Set Fldr = New CDO.Folder
  With Fldr
    .ContentClass = ContentClass
    .Description = Description
    .DataSource.SaveTo Url, , _
                       adModeReadWrite, _
                       adCreateCollection

  End With
  Set CreateFolder = Fldr

End Function


' Note: It is recommended that all input parameters be validated before being used.
Function CreateFolder( Url, ContentClass, Description )
  Set Fldr = CreateObject("CDO.Folder")
  With Fldr
    .ContentClass = ContentClass
    .Description  = Description
    On Error Resume Next
    .DataSource.Open Url, , adModeReadWrite

    If Err.Number <> 0 Then
      Err.Clear
      .DataSource.SaveTo Url, , _
                        adModeReadWrite, _
                       adCreateCollection
      If Err.Number <> 0 Then
       ' Handle error
      End If
    End If
  End With

  On Error Goto 0
  Set CreateFolder = Fldr

End Function



/*
 You must have the following paths in your
 INCLUDE path.
 %CommonProgramFiles%\system\ado
 %CommonProgramFiles%\microsoft shared\cdo

*/
#ifndef _CORE_EXAMPLE_HEADERS_INCLUDED
#define _CORE_EXAMPLE_HEADERS_INCLUDED
#import <msado15.dll> no_namespace
#import <cdoex.dll> no_namespace
#include <iostream.h>
#endif
// Note: It is recommended that all input parameters be validated before being used.
IFolderPtr CreateFolder(bstr_t url, bstr_t contentclass, bstr_t description) {

   if(url == bstr_t(""))
      throw _com_error(E_POINTER);

   _ConnectionPtr Conn(__uuidof(Connection));
   IDataSourcePtr pDsrc(__uuidof(Folder));

   Conn->Provider = "ExOLEDB.DataSource";
   try {
      Conn->Open(url,bstr_t(),bstr_t(),-1);
   }
   catch(_com_error e) {
      throw e;
   }

   IFolderPtr pFldr = pDsrc;

   pFldr->ContentClass = contentclass;
   pFldr->Description  = description;

   try {
      pDsrc->SaveTo(
         url,
         variant_t((IDispatch*)Conn,true),
         adModeReadWrite,
         (RecordCreateOptionsEnum)
            (   adCreateCollection
            ),
         adOpenSource,
         bstr_t(),
         bstr_t());
   }
   catch(_com_error e) {
      cerr << "Error saving folder to store" << endl;
      throw e;
   }

   // Close the connection.
   pConn->Close();
   pConn = NULL;

   return pFldr;
}