Solved

How to send a form request to an email

Posted on 2012-03-17
7
321 Views
Last Modified: 2012-08-14
Hi All,

   I am designing a webpage where in Contacts page, I ask them to submit their details with first name, last name, email, phone number and note and then click submit. When they click submit button, the data should be delivered to an email.

  Any Ideas. Help greatly appreciated.

Thanks
Aman Khan
0
Comment
Question by:amankhan2005
7 Comments
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 250 total points
ID: 37733366
You will use CDO email http://www.paulsadowski.com/wsh/cdo.htm

<%
' this is a basic sample.  I would suggest implementing a captcha and something to scrub html for when you do get spam.  Please check the link for specific examples.  Also you may need to make a few tweaks depending on your hosting.  However, if you send an email "from" the same domain the form sits on, this should work.  If you do need to authenticate, those examples are in the link.

if request.form("somefield")="xyz" then ' send email to me

first_name = request.form("first_name")
last_name = request.form("last_name")
email = request.form("email")
phone = request.form("phone")
note =request.form("note")

'set up the message body
theBody = "New web lead! sent "&now()&"<br>
theBody = theBody& "First: "&first_name&"<br>"
theBody = theBody &"Last: "&last_name&"<br>"
theBody = theBody &"Email: "&email&"<br>"
theBody = theBody &"Phone: "&phone&"<br>"
theBody = theBody &"Note:<br>"&note&

'now send it
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "From Form xyz re: "& first_name&" "&last_name
objMessage.From = "realemail@mydomain.com"
objMessage.To = "anyemail@anydomain.com"
objMessage.TextBody = theBody
objMessage.Send



end if

%>
0
 
LVL 7

Expert Comment

by:markmiddlemist
ID: 37733729
In asp.net the usual way is to use the System.Net.Mail.MailMessage class

There are good examples on the MSDN page - http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 37734182
Here is another way without using the server. It uses html form:
http://www.tizag.com/htmlT/forms.php
You can test it here:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_mail
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:quizwedge
ID: 37750209
Not sure if you're looking for ASP or ASP.NET.

For ASP.NET, use the system.net.mail class that markmiddlemist recommended. If you run into any problems, check out http://www.systemnetmail.com/ It's got a TON of information.

If you're using classic ASP, it depends on what your host offers. A more concise set of examples is at https://help.brinkster.com/KB/a8/how-do-i-send-an-email-with-asp.aspx and a more thorough article is at http://www.devarticles.com/c/a/ASP/Sending-Email-From-a-Form-in-ASP/
0
 
LVL 1

Expert Comment

by:designedbyjackie
ID: 37750321
I built mine using PHP. It is really easy. What is your hosting platform. Is this a static site, or a wordpress site.

There are a ton of basic form widgets for wordpress that you can download and install for free
0
 

Author Comment

by:amankhan2005
ID: 37770692
My Platform is LINUX.

Please find my html file attached where I want to send this form data to an email.

Help Appreciated.
contact.html
style.css
0
 
LVL 1

Accepted Solution

by:
designedbyjackie earned 250 total points
ID: 37772255
I have attached my 2 contact pages so you can see the script and how it works.
This script will run on Linux no problem.. The files are .php

Contact.php is a basic form, no capacha or any bells and whistles.

contactus.php is where all the magic happens and you would just edit the first line $myemail to your email addy.
contact.php
contactus.php
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Running powershell scripts from ASP.NET 6 54
Can Angular be used with classic asp.net? 3 29
Data organization issue 7 36
How to post data to an API using ASP Classic 3 25
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question