Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Contact Form Page email
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

JJenson
Advanced Member

USA
2121 Posts

Posted - 18 February 2007 :  22:55:19  Show Profile  Visit JJenson's Homepage
I created a email form in html and I am using asp to send it to me. this is the code I have I got it from someone else I am unsure why they put a couple lines in it this is the full code and I will post the part in question after:


<%
   if UCase(Request.Form("submit")) = "SUBMIT" then
      SendFormResults "****@*********.com"
   end if

Sub SendFormResults(sendTo)
   Dim results
   results = "Question Form Results:" & vbcrlf & vbcrlf
   
   For Each x in Request.Form
      if Left(x, 3) = "db_" Then
         results = results & Right(x, Len(x)-3) & ": " & Request.Form(x) & vbcrlf
      end if
   Next

   Dim iMsg
   Dim iConf
   Dim Flds
   Dim strHTML

   Const cdoSendUsingPickup = 1

   set iMsg = CreateObject("CDO.Message")
   set iConf = CreateObject("CDO.Configuration")

   ' set the CDOSYS configuration fields to use the SMTP service pickup directory
   Set Flds = iConf.Fields
   With Flds
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
      .Update
   End With

   Set iMsg.Configuration = iConf
   iMsg.To = sendTo
   iMsg.From = sendTo
   iMsg.Subject = "Questions for The Brag Board"
   iMsg.TextBody = results
   iMsg.Send

   set iMsg = nothing
   set iConf = nothing

End Sub
%>


The part I am questioning about and the code I think I can exclude it this: (The part in red is the part I am questioning)

Sub SendFormResults(sendTo)
   Dim results
   results = "Question Form Results:" & vbcrlf & vbcrlf
   
   For Each x in Request.Form
      if Left(x, 3) = "db_" Then
         results = results & Right(x, Len(x)-3) & ": " & Request.Form(x) & vbcrlf
      end if
   Next

   Dim iMsg
   Dim iConf
   Dim Flds
   Dim strHTML


I don't think I need this but I am unsure. Thanks All

Edited by - JJenson on 18 February 2007 22:56:46

JJenson
Advanced Member

USA
2121 Posts

Posted - 19 February 2007 :  11:27:57  Show Profile  Visit JJenson's Homepage
Ok well commmented it out and now it says it sends but it does not send. I am guessing this is because all my fields start with db_ so now I need to take them all out? Anyways any ideas on possibly a different way to do this or word it would be great thanks all. Mainly wondering if someone has a script to send form information they wouldn't mind sharing I would be greatful. Thanks All
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 19 February 2007 :  11:37:57  Show Profile  Visit HuwR's Homepage
first question, Is CDOSYS actually set up on your server ? one of the biggest causes of non-sending mail is that CDOSYS is not actually configured on the server. It is installed and usable by default, but does not actually contain any server information which would allow it t sent emails.
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 19 February 2007 :  12:05:22  Show Profile  Visit JJenson's Homepage
Yes this form will actually send if I prefice the name of the field with a db_ example:

like my name field if I make it db_name it will work but if I take out the db and change it to fname it does not work. I hope this makes sense?

I am trying to change this so I can use a javascript validator I found and I have to adapt one of the code figured this one would be easier.
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 19 February 2007 :  12:07:56  Show Profile
In that case, try changing the for loop to:

For each x in request.form
 results = results&x&": "&request.form(x)&vbcrlf
next
The reason it's checking for "db_" is so that only those fields that pertain to the quix results are included in the body of the e-mail. If your form does not have any fields whose names start with db_ then nothing gets placed in the body of the mail. Without the check, though, all fields will appear in the body so the best way to go about it really, is to retrieve each field individually and build the body of your mail exactly as you want it.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”

Edited by - Shaggy on 19 February 2007 12:10:51
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 19 February 2007 :  12:19:28  Show Profile  Visit JJenson's Homepage
Thanks will give it a go a little later. Thanks guys so basically shaggy you say build my form and then write the code up for the form I created? Just want to make sure I am clear on that.

Thanks All
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 19 February 2007 :  12:27:02  Show Profile
Pretty much; you'll find it much easier to achieve exactly what you want and to change it further down the road, if need be.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 19 February 2007 :  12:29:32  Show Profile  Visit JJenson's Homepage
Well I have never written anything from scratch so I will have a go at it. Does anyone know where I could receive a tutorial or some little guidance online so I can attempt this?
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 19 February 2007 :  12:45:50  Show Profile
Most of it, as far as sending out the e-mail goes, is already in the script you posted above. All you need to do is retrieve each of your form fields individually and append them to the "results" string which is used as the body of the e-mail that gets sent out. To retrieve the value of a field in a form, use request.form("fieldname") where fieldname is the name of the field in your form (e.g., db_name or fname in the example you posted above).


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 19 February 2007 :  13:04:26  Show Profile  Visit JJenson's Homepage
ok so would I need to take out the code in question above and replace that with the request.form("fieldname") ? I think I got how it works cause that code would pretty much become useless I think?

Thanks Shaggy
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 19 February 2007 :  13:06:31  Show Profile
You're welcome Have a play around with it and see how you get on.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 19 February 2007 :  18:00:18  Show Profile  Visit JJenson's Homepage
ok Shaggy i got my validation code working and everything and the email sends but the only thing in the body is

"Contact Results:"

It is not picking up my form for some reason? This is my updated code and yes I know it is not changed alot but I am guessing I put it in the wrong place any help would be greatly appreciated.


<%
   if UCase(Request.Form("submit")) = "SUBMIT" then
      SendFormResults "*****@*********.com"
   end if

Sub SendFormResults(sendTo)
   Dim results
   results = "Question Form Results:" & vbcrlf & vbcrlf
   
   request.form("fname")
   request.form("oname")
   request.form("comments")
   request.form("telephone_number")
   request.form("besttime")
   request.form("zone")
   request.form("email")
   request.form("city")
   request.form("state")
	  
   Dim iMsg
   Dim iConf
   Dim Flds
   Dim strHTML

   Const cdoSendUsingPickup = 1

   set iMsg = CreateObject("CDO.Message")
   set iConf = CreateObject("CDO.Configuration")

   ' set the CDOSYS configuration fields to use the SMTP service pickup directory
   Set Flds = iConf.Fields
   With Flds
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
      .Update
   End With

   Set iMsg.Configuration = iConf
   iMsg.To = sendTo
   iMsg.From = sendTo
   iMsg.Subject = "Questions for The Brag Board"
   iMsg.TextBody = results
   iMsg.Send
   
   set iMsg = nothing
   set iConf = nothing
   
End Sub
%>


Thanks All

Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 20 February 2007 :  05:59:55  Show Profile
To place the value of each field in your results variable, you'll need something like:

results=results&"Fname: "&request.form("fname")&vbnewline
results=results&"Oname: "&request.form("oname")&vbnewline
.
.
.


Where you currently have just:

request.form("fname")
request.form("oname")
.
.
.



Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 20 February 2007 :  09:34:45  Show Profile  Visit JJenson's Homepage
Oh ok I figured it was something like that. I could not find anything over a w3 schools on this or what I needed to call out for. Now this will work for check boxes and radio buttons as well right?

Thanks again shaggy taking baby steps and just starting to go outside the forum and learn so I feel like I know nothing again. the help is much appreciated.
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 20 February 2007 :  09:57:07  Show Profile
Yes, you retrieve the values of radio and checkbox inputs in the same way. Note, though, that if a checkbox is not checked of none of the radio buttons in a group is checked, it will have no value.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 20 February 2007 :  10:13:33  Show Profile  Visit JJenson's Homepage
Yeah thanks shaggy I will make sure to enter that into my java validation code to make sure something is entered.

As always thanks for the help Shaggy someday I might actually get good at this
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07