This script can be used to test CDONTS mail functionality on a server. It’s very straightforward and simple. A typical use for this code is to troubleshoot the service without having to rely on code that could be buried deep in the code of a web app and may have bugs that interfere with the service.
1. Create a file called testcdosys.asp and put it into a site.
2. Insert the code below into the file.
3. Ensure the MailTo and MailFrom fields are modified to valid values.
4. Browse the file in a web browser.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test CDOSYS</title>
</head>
<body bgcolor="#FFFFFF" text="#000033">
<div align="center">
<basefont face="ariallana" color="Black">
<b><font size="+1"><%= error%></font></b>
<p>
<%
message = message & "==========Test==============" & vbCrLf
message = message & "If you received this message, the CDOSYS is working properly on your server" & vbCrLf & vbCrLf
message = message & "Feel Free to modify this script to your needs to get your scripts working properly" & vbCrLf & vbCrLf
' Replace the email address below with your email address to test.'
MailTo = "youremailaddress@youdomain.com"
MailFrom = "CDOSYS-Test@yourdomain.com"
if message <> "" then
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = Server.CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 1 ' cdoSendUsingPickup
.Item(sch & "smtpserver") = "127.0.0.1"
.update
End With
Set cdoMessage = Server.CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = MailFrom
.To = MailTo
.Subject = "CDOSYS Test Mail"
.TextBody = message
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
end if
%><p>Thank you for testing the CDOSYS on this server.<br>
Please check the email for <%= MailTo %> to verify it was successful
</body>
</html>