Can I use ASP Components such as CDONTS, ADONTS, CDO and others on my package?

Knowledge Base

Can I use ASP Components such as CDONTS, ADONTS, CDO and others on my package?

These components are available, but do require ASP.net. Therefore you must be using a Windows hosting package to take advantage of them - they are unsupported by Sun One ASP. 

An example CDONTS script would consists of: 

<% 
Set myCDONTSMail = CreateObject("CDONTS.NewMail") 
Dim myCDONTSMail 
Dim strFrom 
Dim strTo 
Dim strSubject 
Dim strMessage 

strFrom="test@somedomain.com" 
strTo="test@someotherdomain.com" 
strSubject = "Mail sent by CDONTS" 
strBody= "Test message .. please ignore" 

myCDONTSMail.Send strFrom,strTo,strSubject,strBody 

Set myCDONTSMail = Nothing 
%> 

An example CDO script to send mail would be: 


<% 
Dim strEmailAddress, MajorFile, SmtpUser, SmtpPass 
strEmailAddress="test@example.org" 
MajorFile="<h1>Hello</h1>" 
Set cdoConfiguration = Server.CreateObject ("CDO.Configuration") 

With cdoConfiguration 
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 
.Fields.Update 
End With 

Set myMail=CreateObject("CDO.Message") 
myMail.Configuration = cdoConfiguration 
myMail.Subject = "Subject Here" 
myMail.From = "test@someotherdomain.com" 
myMail.To = strEmailAddress 
myMail.HTMLBody = MajorFile 
myMail.Send 
set myMail=nothing 

set cdoConfiguration = nothing 
%> 


A sample CDO script using authenticated SMTP (recommended): 

<!-- #include file="../inc/config.asp" --> 
<% 
' where ../inc/config.asp provides: 
' - SmtpPass: SMTP Password (plain text string) 
' - SmtpUser: SMTP Username e.g. "joe@example.org" 
' - SmtpServer: SMTP Server e.g. "mail.example.com" 

Dim strEmailAddress, MajorFile 
strEmailAddress="test@example.com" 
MajorFile="<h1>Hello</h1>" 

Set cdoConfiguration = Server.CreateObject ("CDO.Configuration") 

With cdoConfiguration 
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SmtpPass 
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = SmtpUser 
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SmtpServer 
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 
.Fields.Update 
End With 

Set myMail=CreateObject("CDO.Message") 
myMail.Configuration = cdoConfiguration 
myMail.Subject = "Subject Here" 
myMail.From = "test@someotherdomain.com" 
myMail.To = strEmailAddress 
myMail.HTMLBody = MajorFile 
myMail.Send 
set myMail=nothing 

set cdoConfiguration = nothing  %>