Share via


IFolder Interface

Topic Last Modified: 2006-06-13

The IFolder interface defines methods and properties used to access a folder in a Microsoft® Exchange 2000 Server public or private store, or a folder in an Exchange store.

CLSID

CD000132-8B95-11D1-82DB-00C04FB1625D

Extends

IDispatch

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Member Summary

The following table lists the properties of the IFolder interface.

Name Description

Configuration

The Configuration CoClass object for the object.

ContentClass

The folder's content class.

DataSource

The IDataSource interface on the object. This property is read-only.

Description

A description of the folder.

DisplayName

The folder's display name. This property is read-only.

EmailAddress

The e-mail address of this folder. This property is read-only.

Fields

The Fields collection for the object. This collection contains the properties for the folder stored in an Exchange store. This property is read-only.

HasSubFolders

Indicates whether the folder contains subfolders. This property is read-only.

ItemCount

The number of nonfolder items in the folder. This property is read-only.

UnreadItemCount

The number of unread items in a folder. This property is read-only.

VisibleCount

The VisibleCount property specifies the number of visible nonfolder items in the folder. For this property, all nonfolder items that are not in the folder's associated contents table (often referred to as non-FAI messages) are visible.

The following table lists the methods of the IFolder interface.

Name Description

GetInterface

Returns the specified dual interface on the object.

Remarks

The Collaboration Data Objects (CDO) Folder CoClass exposes an implementation of the IFolder interface. Folder objects provide access to information about a folder in an Exchange private or public store, or an Exchange store. Such information includes the number of nonfolder items in the folder, the number of unread messages, and whether the folder has subfolders.

Many of the properties exposed on the IFolder interface correspond one-to-one with properties in the Fields Property collection. You can use either the interface properties or the properties in the Fields collection; both methods provide access to folder properties.

The IFolder.DataSource property returns interfaces on the object. Other interfaces may exist, such as IMailRecipient. To access these interfaces, scripting languages use the GetInterface Method. The IMailRecipient interface is present for a Folder object if the CDO for Exchange Management (CDOEXM)Component Object Model (COM) component is installed. Other languages, such as C++ and Microsoft Visual Basic®, can use also an appropriate interface navigation method such as QueryInterface and Set.

Examples

[Visual Basic]

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

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 Or adCreateOverwrite

  End With
  Set CreateFolder = Fldr

End Function

[VBScript]

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 Or adCreateOverWrite
      If Err.Number <> 0 Then
       ' Handle error
      End If
    End If
  End With

  On Error Goto 0
  Set CreateFolder = Fldr

End Function

[C++]

/*
 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

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 |
               adCreateOverwrite
            ),
         adOpenSource,
         bstr_t(),
         bstr_t());
   }
   catch(_com_error e) {
      cerr << "Error saving folder to store" << endl;
      throw e;
   }
   return pFldr;
}