Jump to content

contact form


Recommended Posts

Hi all i'm hoping someone can h elp me after 19 tickets to my hosting company i cannot sort this out so here goes be gentle i am only a novice and my site was built using online videos. right so i have constucted an simple html form for my site and i have downloaded the asp script that my host has available i have the script sending emails but nothing from the form i am not sure how to get the asp script to get the information off my form i have tried lots of other scripts and none have worked this is a last resort before handing it over reluctantly to a web developer these are the scripts. all i recieve on the email is "123 reg is f###ing s###t" do i need to add something in the email body. pleeeese help <form name="feedback"method="post"action="contact/contact.asp"> <ol> <li><label for="name">Name</label> <input type="text"name="name"id="name"></li> <li><label for="telephone">Telephone</label> <input type="text"name="telephone"id="telephone"></li> <li><label for="email">Email</label> <input type="text"name="email"id="email"></li> <li><label for="comments">Comments</label> <textarea name="comments" id="comments" cols="45" rows="5"></textarea></li> <li><input name="submit" type="submit" class="submit" id="submit"value="submit"></li> </ol> </form> (this is my "contact.asp" file) i have remove the website details for this post <%'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''To get the script for work please set the following values:'Set the credentials for your email account to send the email fromusername="test" 'Insert your email account username between the double quotes password="test" 'Insert your email account password between the double quotes 'Set the from and to email addressessendFrom = "info@mywebsite.co.uk" 'Insert the email address you wish to send from sendTo = "info@mywebsite.co.uk" 'Insert the email address to send to in here'DO NOT CHANGE ANY SCRIPT CODE BELOW THIS LINE.'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''This script demonstrates how to send an email using asmtp'Create a CDO.Configuration objectSet objCdoCfg = Server.CreateObject("CDO.Configuration")'Configure the settings needed to send an emailobjCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="intmail.atlas.pipex.net"objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = usernameobjCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = passwordobjCdoCfg.Fields.Update 'Create the email that we are going to sendSet objCdoMessage = Server.CreateObject("CDO.Message")Set objCdoMessage.Configuration = objCdoCfgobjCdoMessage.From = sendFromobjCdoMessage.To = sendToobjCdoMessage.Subject = "123 reg is f###ing s###t"'Add the email body textobjCdoMessage.TextBody = "Email sent using ASMTP from a ASP script." On Error Resume Next 'Send the emailobjCdoMessage.Send'Check if an exception was thrown If Err.Number <> 0 Then 'Response.Write "<FONT color=""Red"">Error: " & Err.Description & " (" & Err.Number & ")</FONT><br/>"Else Response.Write "<FONT color=""Green"">The email has been sent to " & sendTo & ".</FONT>"End If 'Dispose of the objects after we have used themSet objCdoMessage = NothingSet objCdoCfg = NothingSet FSO = nothingSet TextStream = Nothing%> Thanks

Link to post
Share on other sites

You're not getting any of the form data. You use the names of the fields to get the data, e.g. Request.Form("name"), Request.Form("telephone"), etc. Each of those will contain the text from the form field. There are examples of that here: http://www.w3schools.com/asp/asp_inputforms.asp For VBScript, you use the & operator to join text, and VbCrLf is a line break, e.g.: email_body = "Name: " & Request.Form("name") & VbCrLf & "Telephone: " & Request.Form("telephone")

Link to post
Share on other sites

Build your body text first, and then set objCdoMessage.TextBody to your body text. The VbCrLf is so that the text doesn't all show up on the same line, that is how VBScript refers to a line break character.

Link to post
Share on other sites

sorry like i said i am only a novice 1 what is the body text example please ?? how do i set the objcdomessage.textbody to my body text what would i write and where ?? example: how could i just send the email address for starters off my form example ??i triedrespone.write(request.form ("email")) this afteradd email body textsorry i have been try for 2 weeks on this and still no goodthanks for your help

Link to post
Share on other sites

An example of the body text is what I posted in post 2. It is whatever text you want the email to contain. Assuming you store that in a variable called email_body like I wrote, then you would set that variable to be the email's text with "objCdoMessage.TextBody = email_body", or whatever the variable name is. You can also write the body text right on that line if you don't want to use a variable. You need to set that property any time between creating the objCdoMessage object, and sending the email. If you just want to send the email address in the body: objCdoMessage.TextBody = Response.Form("email") The example in post 2 will include the name and phone.

Link to post
Share on other sites

You can write it on multiple lines, but VBScript doesn't like multi-line commands so you'll need to do it like this: email_body = "First Line" & VbCrLfemail_body = email_body & "Second Line" & VbCrLfemail_body = email_body & "Third Line" & VbCrLfemail_body = email_body & "Fourth Line" & VbCrLfetc That would produce text like this: First LineSecond LineThird LineFourth Line

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...