Often, it is necessary to have a page bundle some information and send it out by way of an e-mail message. As simple as that may sound, there are a number of different options that are available to accomplish that task. In addition, there are several pitfalls that need to be avoided.
Sending messages through Active Server Pages (ASP) should not be a difficult task. However, if you are having problems sending messages through ASP, an alternative exists to replace ASPMAIL. The alternative is called Collaboration Data Objects (CDO). While we have received numerous requests to use CDONTS (as opposed to CDO), this cannot be enabled as it requires a local IIS SMTP server. Currently, we cannot provide that service.
However, CDO v.2.0 is a very capable alternate for CDONTS. Built-in to Windows, CDO can be used by the customer to send mail. CDO, as is CDONTS, is configured to work with a local IIS SMTP server by default. However, unlike CDONTS it can be configured for use with a remote SMTP server.
CDO is both powerful and flexible enough to perform most of the major tasks that you may require of it. With CDO, you can send attachments, send to group lists, and send schedules (much as you can with, for instance, Microsoft® Outlook). CDO is easy-to-use and it allows considerable leeway in manipulating the information that gets delivered.
Getting Started
To creating an instance of a CDO object in your ASP code, it is as easy as:
<%
DIM objCDO
Set objCDO = Server.CreateObject("CDO.Message")
%>
Note: To improve the performance on -- and the stability of -- your web site, it is important that you remember to destroy every CDO object that you create. Thus:
<% Set objCDO = Nothing %>
Now you're ready to send those e-mails messages! CDO.Message has a few obvious, easy-to-use properties and methods. That said, let's look at some code that makes the point clearly:
<%
myMail.From = "info@domain.com"
myMail.To = "jsmith@someisp.com"
myMail.Subject = "Information from domain.com"
myMail.Body = "Here's the information you requested"
myMail.Send
%>
CDO has some extraneous features that can be added. Other handlers (methods) such as Cc, Bcc, AttachFile and Importance can be implemented. The Importance property takes three values: 0 (Low), 1 (Normal), 2 (High); its default is 1, Normal.
As mentioned above, some configuration is required to use CDO for Windows (CDOSYS) and a remote SMTP server. A Configuration object is created, populated with configuration information, and then associated with a Message object using the objCDO.Configuration property. The SMTP server name, SMTP connection timeout, and cdoSendUsingPort are the only credentials that are needed.
To create the Configuration object, you would use the following:
<%
Dim objConf
Set objConf = Server.CreateObject("CDO.Configuration")
%>
Here is a list of the configuration fields that are to be used:
Below is another way to specify the configuration fields. This method doesn’t use the schema paths. This is a simpler way of calling the aforementioned paths.
You can import the type library at the top of the page:
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
Note: You can also use the following type library. However, should the file path ever change, we recommend using the first two.
END SUB
fromWho = TRIM( Request.Form( "fromWho") )
toWho = TRIM( Request.Form( "toWho") )
Subject = TRIM( Request.Form( "Subject" ) )
Body = TRIM( Request.Form( "Body") )
If toWho <> "" THEN
sendMail fromWho, toWho, Subject, Body
Response.redirect "confirmation.html"
' Any existing page can be used for the response redirect method
END IF
'Cleanup
Set ObjCDO = Nothing
Set objConf = Nothing
Set objFields = Nothing
%>
Example 2: CDO (E-Mail Script) in its entirety (using CDO & ADODB type libraries)
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%
SUB sendmail( fromWho, toWho, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds
Const cdoSendUsingPort = 2
Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail-fwd"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With
Note that our Technical Support Department does not assist with scripting. The script given here is a test script that you may want to incorporate into your code. You would need to make sure that any paths referenced in the code are correct.
You are so extraordinary to me in light of the fact that your data is so valuable to me. One day I have to make an undertaking on history at https://essayreviewuniverce.com/essay-pro-review/ site and I search a great deal of things however I never discovered great data. Be that as it may, your site is brimming with the intriguing history which is actually so honored for me.