Web Page Support

Exchange Server 2003

Topic Last Modified: 2004-06-09

The CDO libraries offer programmatic support for Hypertext Markup Language (HTML) script on a Web page. Script can be server-side, which is decoded and run at the Web server, or client-side, which is decoded and run at the browser. The CDO Rendering Library supports server-side script, and the CDO Library supports client-side script. For more information on server-side script support, see HTML Rendering.

The language used for the script subroutine can be Microsoft® Visual Basic® Scripting Edition (VBScript), Microsoft® JScript™, or JavaScript. For simplicity of browser implementation, and also for security reasons, not all Visual Basic functionality is available in VBScript. In particular, you cannot use:

  • File input/output or direct operating system access.
  • Early binding, for example Dim objRecip As Recipient.
  • Type library constants, such as CdoPR_DISPLAY_TYPE.
  • Named parameters in calls to methods.
  • Dialog boxes, for example in the Logon method.

For more information on VBScript and its feature restrictions, see the Microsoft Visual Basic Scripting Edition Language Reference.

To use the CDO Library in client-side script, you instantiate a CDO Session object in the body of a Web page, and then log on to this session from a script subroutine. Following logon, you can instantiate and use other objects subsidiary to the session object.

During logon, a MAPI client can only reference a profile that is stored in its own local MAPISVC.INF configuration file. A browser is not likely to be able to access a profile defined and stored at the Web server. Therefore, script running at a browser should create a profile dynamically so that it is local to the browser. This can be done by using the ProfileInfo parameter of the Logon method, or, as in the following example, by calling Logon without parameters and letting the browser user choose a profile.

Dynamic profile creation is only possible on a message service that is tightly coupled with MAPI, such as the Microsoft® Exchange server. Loosely coupled message services cause the MAPI spooler to be started, and if another message service or user tries to access MAPI, serious errors result.

This client-side script fragment sends a feedback message to the Customer Support department when the user clicks the Send Feedback button. It demonstrates a script subroutine in VBScript showing instantiation of a Session object with an HTML <OBJECT> tag. It also shows the subsequent instantiation of a Message object and its Recipients collection, and the preparation and submission of an e-mail message.

Sub Send_Feedback
    Dim objFBMess ' feedback message from Web page
    Dim objRecips ' can't do "Dim As" (early binding) in VBScript
' ... validate objWebSession object instantiated by HTML, then ...
objWebSession.Logon ' let user choose profile if not logged on
    Set objFBMess = objWebSession.Outbox.Messages.Add
    objFBMess.Subject = "Feedback from Web page"
    objFBMess.Text = Feedback.Value
    Set objRecips = objFBMess.Recipients
    objRecips.Add "custsupp" ' send to Customer Support
    objFBMess.Send ' defaults to save copy and no user dialog
End Sub
<B><P>Welcome to the Customer Support Feedback Web page.
<P>If you have any additional suggestions or requests,
<P>please send
<A HREF=MAILTO:user@example.com>Customer Support</A>
some e-mail.
<P>Please enter your feedback here:
<INPUT NAME=Feedback TYPE=Text SIZE=80>
<INPUT ONCLICK=Send_Feedback TYPE=Button VALUE="Send Feedback">
<OBJECT CLASSID="clsid:3FA7DEB3-6438-101B-ACC1-00AA00423326" ID=objWebSession>
<! The OBJECT tag instantiates the CDO Session object>

Note   The <OBJECT> and <SCRIPT> tags and the <LANGUAGE> and <ONCLICK> attributes are defined in the HTML 3.2 specification of the World Wide Web Consortium (W3C). Not all Internet browsers support HTML 3.2 or all of its elements. For more information on HTML 3.2, see the Web page HTML 3.2 Reference Specification at http://www.w3.org/pub/WWW/TR/REC-html32.html.

For more information on the programming elements in the script fragment, see the Session object's Logon and Logoff methods, the Messages collection's Add method, the Message object's Recipients property and Send method, and the Recipients collection's Add and Resolve methods.