Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a form email info to me, aspmail

Status
Not open for further replies.
[tt]
Your form's action is set like this :

action="/cgi-bin/aspmailer2.asp

When it should be set like this:

action="/cgi_bin/aspmailer2.asp
 
Thanks for that, Now I can at least get to the asp. Now I get an error message that my email address is not valid. Any thing you can see there? Thanks Much _ Richard
[wavey3] [wavey3] [wavey3]
 
I would have to see your validation asp page otherwise I don't know.
 
ASP and CGI.....BMW powered by a YUGO engine?
ASP has component that can handle mail A LOT easier...but perhaps there are more resons to why u use CGI...
All the best!

> need more info?
:: don't click HERE ::
 
No particular reason why I am using cgi I just came across it while searching for something that might work for me. I am open to learning soemthing new especially if it works better or eaiser.
The code for the file is
<%@language = &quot;VBscript&quot;%>
<%
'Tom Germain's Standard Cgiware Global Variables and set-up
'DO NOT REMOVE THIS SECTION OR NOTHING WILL WORK
Dim strError
Response.Buffer = True
If ScriptEngineMajorVersion < 2 Then
ReportError &quot;Host system needs scripting engine upgrade to use this script&quot;
End If
Set objFM = CreateObject(&quot;Scripting.Dictionary&quot;)
If IsObject(objFM) = False Then
ReportError &quot;Host system lacks component(s) required by this script&quot;
End If
Set objMailx = CreateObject(&quot;CDONTS.Newmail&quot;)
If IsObject(objMailx) = False Then
ReportError &quot;Host system lacks component(s) required by this script&quot;
End If
Set objMailx = Nothing
%>
<%
'aspmailer.asp by Tom Germain, Copyright 1998-1999
'Version 1.0
'tg@cgiware.com
'Visit for latest version, documentation, and other resources
'This is freeware - Use at your own risk. No warranties provided.
'Redistribution of this program, in whole or in part, is strictly
'prohibited without the expressed written consent of the author.
'Custom programming available on hourly fee basis.
%>

<%'variables you can set start here%>
<%
strRcpt = &quot;richard@noarus.com&quot; 'Put the address you want the form sent to here

strFromVar = &quot;email&quot; 'If you want a reply-to email address to be taken from the form
' put the name of the input item here.

strDefFrom = &quot;ServiceAppointment&quot; 'Put a default, even fake, From address here

strDefSubject = &quot;ServiceAppointment&quot; 'Put the subject of the letter here. If an input item called
'subject exists in the form, its value will be used instead.

strRedirect = &quot;/thanks2.htm&quot; 'Url to redirect to after a successful form submission. If an input item called
'redirect exists in the form, its value will be used instead.

%>
<%'variables you can set end here%>

<%
ParseForm
CheckForm
If Len(strError) > 0 Then
ReportError strError
End If
strOutX = SeqForm
If Len(strOutX) < 1 Then
strOutX = FormToString
End If
If Len(strOutX) < 1 Then
ReportError &quot;Submitted form is empty&quot;
End If
strSubject = strDefSubject
If objFM.Exists(&quot;TGsubject&quot;) Then
strSubject = objFM.Item(&quot;TGsubject&quot;)
End If
strFrom = strDefFrom
If Len(strFromVar) > 0 Then
If objFM.Exists(strFromVar) Then strFrom = objFM.Item(strFromVar) End If
End If
SendMail strFrom,strRcpt,strSubject,strOutX
If Len(strRedirect) > 0 Then
Response.redirect(strRedirect)
Response.End
End If
If objFM.Exists(&quot;TGredirect&quot;) = True Then
If Len(objFM.Item(&quot;TGredirect&quot;)) > 0 Then
Response.redirect(objFM.Item(&quot;TGredirect&quot;))
Response.End
End If
End If
%>
<!--*******SUCCESSFUL SUBMISSION RESPONSE - START*******-->
<!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
<h1>Form Sent!</h1>
<font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Your request has been received
and will be processed shortly</font>.
<!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->
<!--*******SUCCESSFUL SUBMISSION RESPONSE - END********-->

<%
Credit
Response.End
%>
<%
Function IsValidEmail(Email)
Dim Temp,Temp2
strNotValid = &quot;<br>Email address not valid&quot;
strTooLong = &quot;<br>Email address too long&quot;
If Len(Email) > 100 Then
ReportError strTooLong
End If
Email = LCase(Email)
Temp = Split(Email,&quot;@&quot;,2,1)
If UBound(Temp) < 1 Then
ReportError strNotValid
End If
Temp2 = Split(Temp(1),&quot;.&quot;,-1,1)
If UBound(Temp2) < 1 Then
ReportError strNotValid
End If
End Function
%>
<%
Function SendMail(From,Rcpt,Subject,Body)
Trim(From)
Trim(Rcpt)
If Len(From) < 1 Then
ReportError strError & &quot;<br>No Reply-to address (From) for this letter&quot;
End If
If Len(Rcpt) < 1 Then
ReportError strError & &quot;<br>No recipient for this letter&quot;
End If
IsValidEmail Rcpt
IsValidEmail From
Set objMailer = CreateObject(&quot;CDONTS.Newmail&quot;)
objMailer.From = From
objMailer.To = Rcpt
objMailer.Subject = Subject
objMailer.Body = Body
objMailer.Send
Set objMailer = Nothing
End Function
%>
<%
Function CheckForm()
Dim Temp,strTmp,strForce
strInputReq = &quot;<br>Input required for &quot;
If objFM.Exists(&quot;TGrequire&quot;) = False Then
Exit Function
ElseIf isEmpty(objFM.Item(&quot;TGrequire&quot;)) Then
Exit Function
End If
strForce = objFM.Item(&quot;TGrequire&quot;)
Temp = Split(strForce,&quot;,&quot;,-1,1)
For Each strTmp in Temp
If objFM.Exists(strTmp) = False Then
strError = strError & strInputReq & strTmp
ElseIf Len(objFM.Item(strTmp)) < 1 Then
strError = strError & strInputReq & strTmp
End If
Next
End Function
%>
<%
Function ParseForm()
For Each Item in Request.Form
If objFM.Exists(Item) Then
objFM.Item(Item) = objFM.Item(Item) & &quot;,&quot; & Request.QueryString(Item)
Else
objFM.Add Item,Request.Form(Item)
End If
Next
For Each Item in Request.QueryString
If objFM.Exists(Item) Then
objFM.Item(Item) = objFM.Item(Item) & &quot;,&quot; & Request.QueryString(Item)
Else
objFM.Add Item,Request.QueryString(Item)
End If
Next
End Function
%>
<%
Function SeqForm()
Dim Temp,strTmp,strOrder,strOut
If objFM.Exists(&quot;TGorder&quot;) = False Then
Exit Function
ElseIf isEmpty(objFM.Item(&quot;TGorder&quot;)) Then
Exit Function
End If
strOrder = objFM.Item(&quot;TGorder&quot;)
Temp = Split(strOrder,&quot;,&quot;,-1,1)
For Each strTmp in Temp
If objFM.Exists(strTmp) Then
strOut = strOut & strTmp & &quot;=&quot; & objFM.Item(strTmp) & Chr(10)
End If
Next
SeqForm = strOut
End Function
%>
<%
Function FormToString()
Dim strOut
strKeys = objFM.Keys
strValues = objFM.Items
For intCnt = 0 To objFM.Count -1
strOut = strOut & strKeys(intCnt) & &quot;=&quot; & strValues(intCnt) & Chr(10)
Next
FormToString = strOut
End Function
%>
<%
Function ReportError(strMess)
If Len(strMess) < 1 Then
strMess = strError
End If
strErr = &quot;The following error(s) happened: <br>&quot; & strMess
Response.Clear
%>

<!--*******ERRONEOUS SUBMISSION RESPONSE - START*******-->
<!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
<h1>Error!</h1>
<!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->

<%'Error messages will be output here, between your html%>
<%
Response.Write(strErr)
%>
<!--ADD YOUR OWN HTML BOTTOM SECTION STARTING HERE-->
<p> <b>
<input name=&quot;button&quot; type=button onClick=&quot;history.go(-1)&quot; value=&quot;CLICK HERE TO GO BACK AND COMPLETE THE FORM&quot;>
</b></p>
<!--ADD YOUR OWN HTML BOTTOM SECTION UP TO HERE-->
<!--******ERRONEOUS SUBMISSION RESPONSE - END*******-->
<p>
<%
Credit
Response.End
End Function
%>
<%Function Credit%>
<!--START OF CREDIT - DO NOT CHANGE OR REMOVE ANYTHING BELOW THIS LINE-->
<!--END OF CREDIT-->
<%End Function%>
</p>
<p> </p>

[rofl3] [rofl3] [rofl3]
THANKS_Richard
 
eeek all the code...
1st lets learn what we are doing here!

- Form validation
should be done on the form entry-client side by using JS or VBscript. If your are just validating the data-type then I would suggest goign to yaromat.com as he has nice extentions that will work.
Now, if u need to validate your data against some RecordSet value that is a diff. sotry....u have to specify.
-Sending Email
simple CDNOTS
Code:
<%' *** E-mail Vars from recordset &quot;USERS&quot;
  Dim strFirstName
  Dim strEmail
  Dim strAccountName
  Dim strAccountPassword
     strFirstName = Users.Fields.Item(&quot;FirstName&quot;).Value
     strEmail = Users.Fields.Item(&quot;Email&quot;).Value
     strAccountName = Users.Fields.Item(&quot;UserName&quot;).Value
     strAccountPassword = Users.Fields.Item(&quot;Password&quot;).Value
%>
<%' *** SEND MAIL
Dim objCDO
Set objCDO = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objCDO.From = &quot;anyone@dot.com&quot;
objCDO.To = strEmail
objCDO.Subject = &quot;Thank you for registering with [URL unfurl="true"]http://www.hello.com&quot;[/URL]
objCDO.BodyFormat = 0 
objCDO.MailFormat = 0 
objCDO.Body = &quot;<font face='Arial' size ='3'>&quot; &_
&quot;WELCOME &quot; & strFirstName & &quot;!&quot; &_
&quot;<br>&quot; &_
&quot;Thank you for registering with us&quot; &_
&quot;<Br>&quot; &_
&quot;Here is your presonal Account Information :&quot; &_
&quot;<p>&quot; &_
&quot;Username:&quot; & strAccountName &_
&quot;<Br>&quot; &_
&quot;Password:&quot; & strAccountPassword &_
&quot;<p>&quot; &_
&quot;Hello please go to <a href='[URL unfurl="true"]http://hello.com'>http://hello.com</a>[/URL] and :: Log In! :: &quot; &_ 
&quot;<p>&quot; &_
&quot;MORE TEXT&quot; &_ 
&quot;<br>&quot; &_
&quot;<br>&quot; &_
&quot;</font>&quot; 
objCDO.Send()
Set objCDO = Nothing
%>
Of course, values do NOT have to be stored in a recordset...you can simply request them from a form withot storing them in database.
I would suggest 2 pages here (although it an be done on the same page)
FormPage.asp....just the form elements and validtion
with Forms action to &quot;ActionPage.asp&quot;
which would be the one with CDONTS
So without sotred data you request the enterd data in form
Code:
<%' *** E-mail Vars from FORM 
  Dim strFirstName
  Dim strEmail
  Dim strAccountName
  Dim strAccountPassword
     strFirstName = Request.Form(&quot;form_element_name&quot;)     strEmail = Request.Form(&quot;tfEmail&quot;)
....

Again, depents on your setup and if your are trying to record data (eg. user registration) or simply grab it and email it.
post some more
ALl the best!





> need more info?
:: don't click HERE ::
 
I really don't need to have this data go to any data base, I just want to get the email request so someone can call or email the client. No Record Set.
I still am in a fog I guess. I have no AccountName or AccountPassword.
I guess I will go to yaromat.com and check it out.
I guess what you are saying that what I am doing will not work. I am sure that there is alot of code in my cgi that is not needed. Thanks for any clarification of what to place if only wanting to send the values on the form to an email address. Thanks Richard [flush2] [flush2] [flush2]
 
Ok great!
I would suggest to look into as he has some really cool extentions....so just get the one for Fom Validation....IF you need it! DW has some small validation built in.
So very simple version of all this would be:

FormPage.asp or .html
-------------form action:ActionPage.asp------
Your Email: [ email_field]
Address:[address_field]
...
------------------------------------------
and with the form validation applied over it
then on the

ActionPage.asp - which can just process email or give feedback at the same time...
Code:
<%@language = &quot;VBscript&quot;%>

<%' *** E-mail Vars requestedfrom FORM 
  Dim strEmail
  Dim strAddress

strEmail = Request.Form(&quot;email_field&quot;)        
strAddress = Request.Form(&quot;address_field&quot;)

' *** SEND MAIL
Dim objCDO
Set objCDO = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objCDO.From = &quot;YOU@dot.com&quot;
objCDO.To = strEmail
objCDO.Subject = &quot;this works&quot;
objCDO.BodyFormat = 0 
objCDO.MailFormat = 0 

objCDO.Body = &quot;YOUR BODY OF THE MSG GOES HERE&quot; &_
&quot;Here is your Information :&quot; &_
&quot;<p>&quot; &_
&quot;EMAIL:&quot; & strEmail &_
&quot;<p>&quot; &_
&quot;ADDRESS:&quot; & strAddress &_

objCDO.Send()
Set objCDO = Nothing
%>
<% Response.Write(&quot;Email Sent&quot;) %>

What matters is that you rememeber the names of form elements as you will request them on ActionPage....in this case I called them 'email_field' and 'address_field' but u can call them anything u like!
thats all....no need for CGI or crazy cripts....
again u can find form validation in Behaviors Tab!
All the best!

> need more info?
:: don't click HERE ::
 
well, my brain is starting to hurt. I will have to study this stuff more later. I think I should just start from scratch because I think I am confused. Thanks for you time and have a great weekend. Richard [bomb] [yawn2] [bomb]
 
Hi RIchard!
Don't worry...you will get it....it is better to go step by step than decode someone eleses code!
Give it another try...


All the best!

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top