# ASP Form Mail Help for a newbie



## AussieDreamer (Feb 19, 2008)

I'm a total newbie at asp form mails and have just set one up fairly successfully. Despite searching I cannot find the correct syntax to use for the two drop down boxes that are in the form. The form code can be seen below. The two fields in question are:-

Mail.BodyText = Request.Form("Title")
Mail.BodyText = Request.Form("ordernow")

I know that the Mail.BodyText is not the correct syntax for drop down boxes as it doesn't come through in the email.

Also I would like to have the email formatted to look something like this:-

*First Name:* John Smith

I did see an example that was posted in these forums here at http://www.asp101.com/articles/john/templates/default.asp but didn't understand how to incorporate that into my asp code which is shown below. Any help would be much appreciated.

This is my asp code:-

<% @LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%

Set Mail = Server.CreateObject("SMTPsvg.Mailer") 'create an Asp mail component.
Mail.FromName = "mywebsite.com"
Mail.FromAddress= Request.Form("email")
Mail.RemoteHost = "mrvnet.kundenserver.de" ' The mail server you have to use with Asp Mail
Mail.AddRecipient "My Name", "[email protected]"
Mail.Subject = "Website - Info Request"
Mail.BodyText = Request.Form("Title")
Mail.BodyText = Request.Form("firstname")
Mail.BodyText = Request.Form("lastname")
Mail.BodyText = Request.Form("address")
Mail.BodyText = Request.Form("addr2")
Mail.BodyText = Request.Form("addr3")
Mail.BodyText = Request.Form("county")
Mail.BodyText = Request.Form("postcode")
Mail.BodyText = Request.Form("email2")
Mail.BodyText = Request.Form("ordernow")
Mail.BodyText = Request.Form("quantity")
Mail.BodyText = Request.Form("comments")

if Mail.SendMail then
Response.redirect "form_thankyou_response.shtml"
else
Response.Write "Mail send failure. Error was " & Mail.Response
end if 
Set Mail = Nothing
%>



And this is my form:-



 
Select title...
Mr
Mrs
Ms

Dr
Miss
*First Name *
*Last Name *
*Delivery Address*
  *County**Postcode*
*Email*

*Order Now *
A5 Flyers
A4 Flyers

A3 Posters
A2 Posters
A1 Posters
4 Page Brochure
8 Page Brochure
Greeting Cards

NCR Sets
Business Pack
Business Cards
Compliment Slips
Letterheads
Tickets

*Enter Quantity**Please enter
specific details of
your order here.*


----------



## Fyzbo (Feb 6, 2002)

I'm not sure of what you are asking, but I can make some pointers on your code.

1. You will want to check that the form was submitted before executing the asp code to send an email. You can simply check if one of the required form variables exists, if it does send the email if not don't.

2. You are replacing Mail.BodyText every time you set it. So in the end it is just comments, you will want to append the additional text.

This code is not tested!


```
<% @LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%

If (Request.Form("Title")) Then
	Set Mail = Server.CreateObject("SMTPsvg.Mailer") 'create an Asp mail component.
	Mail.FromName = "mywebsite.com"
	Mail.FromAddress= Request.Form("email")
	Mail.RemoteHost = "mrvnet.kundenserver.de" ' The mail server you have to use with Asp Mail
	Mail.AddRecipient "My Name", "[email protected]"
	Mail.Subject = "Website - Info Request"
	Mail.BodyText = Request.Form("Title")
	Mail.BodyText += Request.Form("firstname")
	Mail.BodyText += Request.Form("lastname")
	Mail.BodyText += Request.Form("address")
	Mail.BodyText += Request.Form("addr2")
	Mail.BodyText += Request.Form("addr3")
	Mail.BodyText += Request.Form("county")
	Mail.BodyText += Request.Form("postcode")
	Mail.BodyText += Request.Form("email2")
	Mail.BodyText += Request.Form("ordernow")
	Mail.BodyText += Request.Form("quantity")
	Mail.BodyText += Request.Form("comments")

	if Mail.SendMail then
	Response.redirect "form_thankyou_response.shtml"
	else
	Response.Write "Mail send failure. Error was " & Mail.Response
	end if
	Set Mail = Nothing
End If
%>

And this is my form:-

[TABLE]

[TR]
[TD] [/TD]
[TD]
Select title...
Mr
Mrs
Ms

Dr
Miss
[/TD]
[/TR]
[TR]
[TD][B]First Name [/B][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD][B]Last Name [/B][/TD]
[TD]
[/TD]
[/TR]
[TR]

[TD][B]Delivery Address[/B][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD][/TD]
[/TR]

[TR]
[TD] [/TD]
[TD][/TD]
[/TR]
[TR]
[TD][B]County[/B][/TD]
[TD][/TD]
[/TR]

[TR]
[TD][B]Postcode[/B][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD][B]Email[/B][/TD]
[TD]

[/TD]
[/TR]
[TR]
[TD][B]Order Now [/B][/TD]
[TD]
A5 Flyers
A4 Flyers

A3 Posters
A2 Posters
A1 Posters
4 Page Brochure
8 Page Brochure
Greeting Cards

NCR Sets
Business Pack
Business Cards
Compliment Slips
Letterheads
Tickets

[/TD]
[/TR]
[TR]
[TD][B]Enter Quantity[/B][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][B]Please enter
specific details of
your order here.[/B][/TD]

[TD]

[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]   

[/TD]
[/TR]

[/TABLE]
```


----------

