Jump to content

Get a 'submit button' to automatically submit to an email address


annyvz

Recommended Posts

Hi there,

 

I am VERY new to asp and need help please!

 

I have a form with a submit button, but I need the form to automatically submit to a mail address

 

my code:

 

<form class="pure-form pure-form-stacked" method="POST" action="tizagEmail.asp"> <fieldset> <legend><strong>Personal Information</strong></legend><br> <div class="pure-g"> <div class="formstyle"> <label for="first-name">First Name</label> <input id="first-name" type="text"> </div> <div class="formstyle"> <label for="last-name">Last Name</label> <input id="last-name" type="text"> </div> <div class="formstyle"> <label for="email">E-Mail</label> <input id="email" type="email" required> </div> <div class="formstyle"> <label for="state">Exam Level</label> <select id="state" class="pure-input-1-2"> <option>Level 1</option> <option>Level 2</option> <option>Level 3</option> </select> </div> </div> <br><form class="formstyle"><script>DateInput('orderdate', true, 'DD-MON-YYYY')</script></form><br><input type="submit" value="Submit"></form>

 

---------------------------------------------------------------------------------------------------------------------------------------

 

My asp code:

 

<%'Sends an emailDim mailSet mail = Server.CreateObject("CDO.Message")mail.To = Request.Form("To:annalin@ctrack.co.za")mail.From = Request.Form("From:issuetr@digicore.co.za")mail.Subject = Request.Form("Subject:Exam Registration")mail.TextBody = Request.Form("Body")mail.Send()Response.Write("Mail Sent!")'Destroy the mail object!Set mail = nothing%>

 

Please help me where my mistake is lying that this form wont automatically submit

 

Thank you!

post-175273-0-23080900-1407147251_thumb.jpg

Link to comment
Share on other sites

What happens when you submit the form? Are there any error messages?You have a form inside the form. A form cannot contain another form, remove the inner form.You're not using request.form correctly. You should change your inputs to use names:<input type="text" name="user_email_address">Then you get those values from request.form using the input name:Request.Form("user_email_address")If you're using a hard-coded value then you don't need Request.Form.mail.Subject = "Exam Registration"

Link to comment
Share on other sites

Hi,

 

Thank you so much for your response!

 

I have removed the extra form tags..

 

I have a couple of questions:

 

1. Does the <input type="text" name="user_email_address"> go into my html file, and the Request.Form("user_email_address") into my seperate .asp file?

 

2. How do I code the input on the parts of the form, like the calendar and dropdown list, to obtain those values to go into the mail that is automatically sent?

 

e.g.

 

<div class="formstyle"> <label for="state">Exam Level</label> <select id="state" class="pure-input-1-2"> <option>Level 1</option> <option>Level 2</option> <option>Level 3</option> </select> </div>

 

3. Is the code in my asp file correct, or can I change it to:

 

<%Set myMail=CreateObject("CDO.Message")myMail.Subject="Exam Registration"myMail.From="issuetr@digicore.co.za"myMail.To="issuetr@digicore.co.za"myMail.TextBody="This is a message."myMail.Configuration.Fields.Item _("http://schemas.microsoft.com/cdo/configuration/sendusing")=2'Name or IP of remote SMTP servermyMail.Configuration.Fields.Item _("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com"'Server portmyMail.Configuration.Fields.Item _("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25myMail.Configuration.Fields.UpdatemyMail.SendResponse.Write("Mail Sent!")'Destroy the mail object!set myMail=nothing%>

 

I REALLY appreciate your help!!!

Link to comment
Share on other sites

Does the <input type="text" name="user_email_address"> go into my html file, and the Request.Form("user_email_address") into my seperate .asp file?

Right. The HTML form says how to submit the data, that's what the input names are for. The data will be submitted with that name. In ASP, you get the data using the same name with which it was submitted.

How do I code the input on the parts of the form, like the calendar and dropdown list, to obtain those values to go into the mail that is automatically sent?

The same way, with a name attribute. A select element, textarea, input, etc all can (and should) have a name attribute. For a select element, the value that gets submitted will be the value of the option that they chose.

Is the code in my asp file correct, or can I change it to:

The new code looks fine, but it doesn't use any of the form data. You can fill out the email body with the contents of Request.Form to add the data they submitted.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...