Support - Knowledge base

Giving you the answers you need

Why not try our knowledge base for instant help and advice to enhance your online experience with Register365? From within the knowledge base you can browse our frequently asked questions and find the right answers to help solve your queries.

Home  >  Scripting  >  ASP (Active Server Pages)  >  View Article

Example working CDONTS script

5*5*5*5*5*

Article

<% 
' Example script using CDONTS 
'    
' *********************************************** 
' ***** SET SOME MAIL VARIABLES             ***** 
' *********************************************** 
'  
'  
' THESE MUST BE VALID EMAIL ADDRESSES  
mailFrom = "website@domain.com" 
mailTo = "user@domain.com" 
mailSubject = "A test message" 
' *********************************************** 
' ***** SET UP THE BODY TEXT                ***** 
' *********************************************** 
lineEnd = "<br> " & Chr(13) & Chr(10) 
mailBody = "This is a test message" & lineEnd 
mailBody = mailBody & "Sent from an online script" & lineEnd 
mailBody = mailBody & "using CDONTs" & lineEnd 
mailBody = mailBody & "Sent from " & mailFrom & lineEnd 
' *********************************************** 
' ***** EMAIL IMPORTANCE                    ***** 
' ***** 0 = LOW     1 = NORMAL     2 = HIGH ***** 
' *********************************************** 
mailImportance = "1" 
' *********************************************** 
' ***** SEND THE MAIL                       ***** 
' *********************************************** 
Set mailmsg = Server.CreateObject("CDONTS.NewMail") 
mailmsg.Bcc = mailFrom 
mailmsg.BodyFormat = 0 
mailmsg.Send mailFrom, mailTo, mailSubject, mailBody, mailImportance 
%>  
<html> 
<head> 
<title>Mail Sent</title> 
<style type="text/css"> 
<!-- Hide from older browsers  
html, body { border: 0; margin: 0; } 
body { background-color: #FFF; color: #333; font-family: verdana, arial, helvetica, geneva, sans-serif; font-size: 0.9em; margin: 20px; padding: 0; text-align: center; } 
h1 { font-size: 1.5em; text-align: center; font-weight: bold; color: #F00; background-color: #CCC; } 
h2 { font-size: 1.2em; text-align: center; font-weight: bold; padding: 1px 5px 1px 5px; } 
h3 { font-size: 1.2em; text-align: left; font-weight: bold; background-color: #ff7a0f; padding: 1px 5px 1px 5px; } 
#content { width: 400px; text-align: left; overflow: auto; background-color: #FFF; border: 1px solid #000; } 
#content p { padding: 0 5px 0 5px; } 
#content a { color: #05F; text-decoration: none; } 
#content a:hover { color: #F50; text-decoration: underline; } 
--> 
</style> 
</head> 
<body> 
<center> 
<div id="content"> 
<h1>MAIL SENT</h1> 
<p>An email has been sent to <% Response.Write (mailTo) %> from <% Response.Write (mailFrom) %>. Please check the relevant mailbox</p> 
</div> 
</center> 
</body> 
</html>

Rate This Article

How useful was this article?

Not useful A little useful Useful Very useful Everything I needed