Autodetect CDO

E

Eric Caron

Hi everybody,

Is there a way to detect whether to use CDO (CDOSYS) or CDONTS, depending on
the platform used? Any code sample?

Thanks in advance,

Eric.
 
S

Steven Burn

<%
If CheckObject("CDONTS.NewMail") <> True Then
Response.Write "CDONTS is not available"
Else
Response.Write "CDONTS is available"
End If
If CheckObject("CDO.Configuration") <> True Then
Response.Write "CDO is not available"
Else
Response.Write "CDO is available"
End If

Function CheckObject(sObject)
On Error Resume Next
Set objClass = CreateObject(sObject)
If Err.Number <> 0 then
'// An error occured, return false
CheckObject = False
Else
If IsObject(objClass) Then CheckObject = True
End If
Set objClass = Nothing
End Function
%>


--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
D

Dave Anderson

Eric said:
Is there a way to detect whether to use CDO (CDOSYS) or CDONTS,
depending on the platform used? Any code sample?

try {
var Message = Server.CreateObject("CDO.Message")
}
catch(e) { ...repeat as required for CDONTS... }


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
E

Eric Caron

Thanks Steven!

I was looking for a more complicated method of identifying the platform, but
your solution is simple et elegant. Is there a reason you would check for
the Configuration object instead of Message?
 
E

Eric Caron

Try...Catch only works with .NET tho. This is for an older project. Thanks
for the suggestion.

Eric.
 
D

Dave Anderson

Eric said:
Try...Catch only works with .NET tho. This is for an older project.
Thanks for the suggestion.

Incorrect. I use it every single day in classic ASP.




--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
M

Michael D. Ober

Is it part of the JScript language? It's definitely not part of VBScript.

Mike Ober.
 
D

Dave Anderson

Michael said:
Is it part of the JScript language? It's definitely not part of
VBScript.

It is.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,834
Members
47,382
Latest member
MichaleStr

Latest Threads

Top