?
Solved

How to send a form request to an email

Posted on 2012-03-17
7
Medium Priority
?
335 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 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1000 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 1000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

850 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