Platform SDK: CDO for Windows 2000

Putting the Configuration Object in the ASP Session

If you use CDO for Windows 2000 within ASP applications, place the Configuration object in the ASP Session object, and reuse it from page to page. This can increase performance for the user because each page does not have to re-create and reset all of the configuration fields. If you do not request configuration information from the user, you can populate and cache the object in the Session_OnStart event subroutine in the application's global.asa file. For example,

global.asa

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<SCRIPT RUNAT=Server LANGUAGE=VBScript>
Sub Session_OnStart()
 Dim iConf
 Dim Flds
 Set iConf = CreateObject("CDO.Configuration")
 Set Flds = iConf.Fields
 With Flds
  .Item(cdoSendUsingMethod)           = cdoSendUsingPickup
  .Item(cdoSMTPServerPickupDirectory) = "c:\Inetpub\mailroot\Pickup"
  .Update
 End With
 Set Session("Config") = iConf
End Sub
</SCRIPT>

Next, you access the global configuration information with ASP pages as follows:

send.asp

<%
 ' use cached settings for Session…
  Set iMsg.Configuration = Session("Config")
  iMsg.To   = "userA@microsoft.com"
  iMsg.From = "userB@microsoft.com"
  ' …
  iMsg.Send
%>