Print Page | Close Window

CDONTS - help required, please!

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=136
Printed Date: 30 March 2026 at 2:45pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: CDONTS - help required, please!
Posted By: madHatter
Subject: CDONTS - help required, please!
Date Posted: 13 February 2003 at 2:02pm

Hello

I am writing in the hope somebody can assist me with some code. I don't think it is too complicated, but I have had no luck with it.

I have two ASP pages, one with a form (ASP1) on it, and one which is a 'Thank you' page (ASP2).

On ASP1, I have a script which personalises ASP2 (as in 'Thank you John') and which also checks that all form fields have been completed:

<%
If Request.Form.Count > 0 Then
    Name  = Trim(Request.Form("t1"))
    Email     = Trim(Request.Form("t2"))
    Message  = Request.Form("S1")

session("t1") = request.form("t1")
  
   
    'data validation
    If Name = "" Then
        ErrorMsg = ErrorMsg & "Please enter your name<br>"
    End If
    If Email = "" Then
        ErrorMsg = ErrorMsg & "Please enter your email address<br>"
    End If
    If Message = "" Then
        ErrorMsg = ErrorMsg & "Please write your message<br>"
    End If
  

    If ErrorMsg = "" Then
        'use this to perform any database validations
       
        'when the name, email and message fields have been checked, redirect the visitor
        Response.Redirect "welcome1.asp"
    End If
End If
%>

<form action="<%= Request.ServerVariables("SCRIPT_NAME") %>" method=post>

<% If ErrorMsg <> "" Then %>
    <p><font color="#FFFFFF"><b><%= ErrorMsg %></b></font><p>

<% End If %>

The form fields concerned are as follows:

<input type=text name=t1 value="<%= t1 %>">
<input type=text name=t2 value="<%= t2 %>">
<textarea name=S1 value="<%= S1 %>"></textarea>

On ASP2, I have:

<p>Thank you <%= session("t1") %></p>

which is the script which personalises the page.

Also on ASP2, and unrelated to the above script, I have the following CDONTS code:

<%
Dim t1name,t1,t2name,t2
t1name = "name"
t1 = Request.Form("t1")
t2name = "email"
t2 = Request.Form("t2")
Dim stname,st
stname = "comments"
st = Request.Form("s1")
Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = " mailto:me1@aol.com - me1@aol.com "
ObjMail.CC = t2
ObjMail.From = t2
ObjMail.Subject = "Feedback"
ObjMail.Body = t1name & vbcrlf&_
t1 & vbcrlf&_
t2name & vbcrlf&_
t2 & vbcrlf&_
stname & vbcrlf&_
st
ObjMail.Send
Set ObjMail = Nothing
%>

My message to this forum conerns this: the CDONTS code should send an email to the Webmaster and a copy to the person who filled in the form. It doesn't work, and I can't understand why, though I suspect it is something to do with the variables.

If anybody can help, I would be grateful (and please forgive the names which I have given to the variables).

Best wishes

madHatter




Replies:
Posted By: michael
Date Posted: 13 February 2003 at 3:12pm
When you say it does not work; what do you mean? Do you get an error message, does the mail not get send?? Some more detail would help troubleshooting your problem.


Posted By: madHatter
Date Posted: 13 February 2003 at 3:49pm

Hello Michael

Many thanks for your message.

The CDONTS does work as a script - that is, there is nothing wrong with its logic - at least, nothing that I know of. I have tested it elsewhere, and it does send out a message to the Webmaster and a copy to the person who completed the form.

But no, on the site above (please see my first posting), it doesn't work. That is, it doesn't actually send any messages out. I have the CDONTS set up so that I am both the Webmaster (an email should go to the Webmaster's email address) and the site visitor (a different email box that I use) and.........nothing! No messages received.

I suspect the problem lies with the variable t1 or "t1" or <%t1%> or something like that, because as I mention, the CDONTS script itself runs fine elsewhere.

Thanks for your help, I'm grateful.

madHatter



Posted By: michael
Date Posted: 13 February 2003 at 5:21pm
Well the logic itself seems fine though I am not using CDONTS so might be wrong. A problem that I encounter on some server though is that mail is just rejected as either they must be sent to a mailbox of the same domain or the recipient server has the originater listed as a spam server so does not allow it. A lot of mail servers that are used by many users in a hosting environment are abused so get listed pretty quick.


Posted By: MorningZ
Date Posted: 13 February 2003 at 9:21pm
its time to rule out (1) your code or (2) improper CDONTS setup..

run a little test script first, see if you get the mail, then report back

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=25 - super simple test script

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: madHatter
Date Posted: 14 February 2003 at 1:38am

Hello MorningZ

Many thanks for your message.

The script is now working fine.

There was nothing wrong with the CDONTS code, but I had it placed on the 'Thank you' page and not the form page. I did this because I thought the variables used behind the form were related to the CDONTS script - which they weren't until I transferred the CDONTS from one asp file to another.

Many thanks to both of you on this forum for all your time, suggestions, and efforts. I'm grateful again.

Best wishes

madHatter 

 



Posted By: jkeck
Date Posted: 05 August 2003 at 9:53pm

As someone just learning ASP the above dialogue has been very helpfull, thanks.

Now My question is this: I have created a similar form using the same validation technique. However I find it a bit unhelpfull that when the error messages are returned that the form is wiped clean and the user must re-enter all the fields.

Is there a way to retain the fields that passed the validation check so the user can simply finish the form and re-submit it?

Thanks

Josh




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net