Writing a Rendering Application

To render CDO objects and properties into HTML hypertext, you instantiate a rendering object such as a ContainerRenderer or ObjectRenderer object. These are top-level objects, which can be created directly by your code without deriving them from any other object. For more information, see CDO Rendering Objects.

The recommended approach, however, is to begin by instantiating a RenderingApplication object, from which you can create a family of related rendering objects. The RenderingApplication object allows you to set options which are inherited by every rendering object you create from it. You can choose the verbosity of event logging in each of several categories using the LoggingLevel property, set the code page for character representation with the CodePage property, and prepare specific rendering information through the Formats property. These options act as global presettings for your entire rendering application. The individual rendering objects can change their inherited copies of the code page and the formats if appropriate.

The next step is to use the CreateRenderer method to instantiate a specific rendering object, such as a ContainerRenderer or ObjectRenderer object. The rendering object is used to generate HTML hypertext from a CDO object. You create a container renderer if you want to render the contents of a container object, such as an address book container or a folder. You create an object renderer if you only want to render one or more selected properties of an object, such as when a message was sent and received.

After you create the rendering object, you set its DataSource property to specify the object or collection you want to render. The container renderer's DataSource property accepts an AddressEntries, Folders, Messages, or Recipients collection. The object renderer's DataSource property accepts an AddressEntry, AppointmentItem, Attachment, Folder, MeetingItem, or Message object.

Every rendering object has a child Formats collection, which is originally inherited from the parent RenderingApplication object but can be modified as needed. You can add a new Format object with the collection's Add method and delete a format with the Format object's Delete method. You should make changes to the Formats collection before setting the DataSource property; otherwise they are not reflected in the rendering of the new data source.

A Format object provides information for rendering one property of the object being rendered, or one property of the items in the container object being rendered. Each format controls exactly one property, and each property to be rendered must be represented by exactly one format. You specify the property in the format's Property property. The rendering information is contained in the format's Patterns collection, which is accessed with the format's Patterns property.

Each Pattern object furnishes information for rendering a particular set of values of the property. You specify the value set in the pattern's Value property and a rendering source for that value set in the RenderUsing property. The rendering source is a string containing HTML hypertext and substitution tokens. When the property's value matches a pattern's value set, that pattern's rendering source is used to render the property.