Before you CreateObject for CDONTS or FSO could yo

Results 1 to 2 of 2

Thread: Before you CreateObject for CDONTS or FSO could yo

  1. #1
    Join Date
    Dec 1969

    Default Before you CreateObject for CDONTS or FSO could yo

    &nbsp;<BR>Is there a VBScript command that can be used to determine whether an object can be created or not? ?In other words, is there a way in ASP to determine if the server has a certain (ActiveX/DLL) component installed/enabled or not - before initiating the CreateObject() function?<BR><BR>Why? - As a Web Designer, I often use the same scripts on different servers/NT Web-hosts. Some of those servers have certain ASP features disabled such as: FSO (File System Object) or CDONTS (Collaborative Data Objects), some servers don&#039t.<BR><BR>For example: Say in my script below, I would want to take advantage of the CDONTS email rich features that most FORM-MAIL programs lack. If CDONTS were not available then it would go to my 2nd choice: a generic CGI FORM-MAIL program. So then, what condition would I have to write to find out if the CDONTS component is available?<BR><BR>(Fill in the blank for the script below:)<BR>&#060;% <BR>If ____________ Then &#039CDO is available<BR>Set objMail = CreateObject("CDONTS.NewMail")<BR>objMail.From = strMyAddress<BR>objMail.To = ""<BR>objMail.Subject = "CDO Mail Works!!!"<BR>&#039 ?and so on.<BR>objMail.Send<BR>Else &#039CDO is not available<BR>Response.Redirect("/cgi-bin/")<BR>End If<BR>%&#062;<BR><BR>(I tried without success the "IsObject(*)" function, but this function was obviously intended for after the "Set" command - so back to square one!)<BR>?Since I don&#039t have such a condition in place, I get the following error on the servers that don&#039t support CDONTS:<BR><BR>Microsoft VBScript runtime error &#039 800a01ad&#039 <BR>ActiveX component can&#039t create object: &#039CDONTS.NewMail&#039 <BR><BR>Thanking anyone in Advance<BR>

  2. #2
    C.W. Guest

    Default RE: Before you CreateObject for CDONTS or FSO coul

    Why dont you just trap the error, check to make sure the code matches the cant create object code and go from there?<BR><BR>In fact, if you did this at the application level, you could set an application variable to identify which method to use throughout. That way the error code would only have to run once per application start.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts