AllExperts > Active Server Pages Programming (ASP) 
Search      
Active Server Pages Programming (ASP)
Volunteer
Answers to thousands of questions
 Home · More Active Server Pages Programming (ASP) Questions · Answer Library  · Encyclopedia ·
More Active Server Pages Programming (ASP) Answers
Question Library

Ask a question about Active Server Pages Programming (ASP)
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Ashvin Johnson
Expertise
I can handle all the queries about File handling, ASP with XML, XSLT, ASP with SQL server 2000 and ASP links.

Experience
I have 3 years of experience in Active server pages programming. I have 2 years of experience in .net applications. I have developed many sites in ASP.net. Please mention your platform on which you are working. for e.g. ASP Classic or ASP.NET

Organizations belong to
I am working in a Data conversion company. We work for the Internet content preparation. My job is to develope utilities to increase production with accuracy.

 
   

You are here:  Experts > Computing/Technology > Business Software > Active Server Pages Programming (ASP) > HTML to EMAIL using asp

Active Server Pages Programming (ASP) - HTML to EMAIL using asp


Expert: Ashvin Johnson - 3/6/2005

Question
I am using a simple form in html to move information to email. The .asp program is as follows:

<%
For Each x In Request.Form
message=message & x & ": " & Request.Form(x) & CHR(10)
Next

set smtp = Server.CreateObject("Bamboo.SMTP")
' You only need to change the smtp.Rcpt ans smpt.from part to your email address
smtp.Server = "mail.nwsoccer.net"
smtp.Rcpt = "kgwortman@charter.net"
smtp.From = "webmaster@nwsoccer.net"
smtp.FromName = Request.ServerVariables("HTTP_REFERER")
smtp.Subject = "Your web form - " & Request.ServerVariables("HTTP_REFERER")
smtp.Message = message
on error resume next
smtp.Send
if err then
response.Write err.Description
else
response.Write ("Thank you for your submission.... Your message has been delivered successfully.")
end if
set smtp = Nothing
%>

The above works fine.   However, I need to format the email so the information is readble and comes in the email in the order I need it so my programming is below:

<%

Season = Request.Form("Season")
Year = Request.Form("Year")
ClubName = Request.Form("ClubName")
BoysDivision1Only = Request.Form("BoysDivision1Only")

AgeGroup1 = Request.Form("AgeGroup1")
CoachName1 = Request.Form("CoachName1")
Phone1 = Request.Form("Phone1")
CoacheMail1 = Request.Form("CoacheMail1")
HomeField1 = Request.Form("HomeField1")

AgeGroup2 = Request.Form("AgeGroup2")
CoachName2 = Request.Form("CoachName2")
Phone2 = Request.Form("Phone2")
CoacheMail2 = Request.Form("CoacheMail2")
HomeField2 = Request.Form("HomeField2")

AgeGroup3 = Request.Form("AgeGroup3")
CoachName3 = Request.Form("CoachName3")
Phone3 = Request.Form("Phone3")
CoacheMail3 = Request.Form("CoacheMail3")
HomeField3 = Request.Form("HomeField3")

AgeGroup4 = Request.Form("AgeGroup4")
CoachName4 = Request.Form("CoachName4")
Phone4 = Request.Form("Phone4")
CoacheMail4 = Request.Form("CoacheMail4")
HomeField4 = Request.Form("HomeField4")

AgeGroup5 = Request.Form("AgeGroup5")
CoachName5 = Request.Form("CoachName5")
Phone5 = Request.Form("Phone5")
CoacheMail5 = Request.Form("CoacheMail5")
HomeField5 = Request.Form("HomeField5")

AgeGroup6 = Request.Form("AgeGroup6")
CoachName6 = Request.Form("CoachName6")
Phone6 = Request.Form("Phone6")
CoacheMail6 = Request.Form("CoacheMail6")
HomeField6 = Request.Form("HomeField6")

AgeGroup7 = Request.Form("AgeGroup7")
CoachName7 = Request.Form("CoachName7")
Phone7 = Request.Form("Phone7")
CoacheMail7 = Request.Form("CoacheMail7")
HomeField7 = Request.Form("HomeField7")

ClubContact = Request.Form("ClubContact")
Address1 = Request.Form("Address1")
Address2 = Request.Form("Address2")
CitySt = Request.Form("CitySt")
Telephone = Request.Form("Telephone")
eMail = Request.Form("eMail")

message = message & "Boys Division 1 Only: " & BoysDivision1Only & VBCrLf
message = message & "Season: " & Season & VBCrLf
message = message & "Year: " & Year & VBCrLf
message = message & "Club Name: " & ClubName & VBCrLf

message = message & "Age Group 1: " & AgeGroup1 & VBCrLf
message = message & "Coach Name 1: " & CoachName1 & VBCrLf
message = message & "Phone 1: " & Phone1 & VBCrLf
message = message & "Coach eMail 1: " & CoacheMail1 & VBCrLf
message = message & "Home Field 1: " & HomeField1 & VBCrLf

message = message & "Age Group 2: " & AgeGroup2 & VBCrLf
message = message & "Coach Name 2: " & CoachName2 & VBCrLf
message = message & "Phone 2: " & Phone2 & VBCrLf
message = message & "Coach eMail 2: " & CoacheMail2 & VBCrLf
message = message & "Home Field 2: " & HomeField2 & VBCrLf

message = message & "Age Group 3: " & AgeGroup3 & VBCrLf
message = message & "Coach Name 3: " & CoachName3 & VBCrLf
message = message & "Phone 3: " & Phone3 & VBCrLf
message = message & "Coach eMail 3: " & CoacheMail3 & VBCrLf
message = message & "Home Field 3: " & HomeField3 & VBCrLf

message = message & "Age Group 4: " & AgeGroup4 & VBCrLf
message = message & "Coach Name 4: " & CoachName4 & VBCrL
message = message & "Phone 4: " & Phone4 & VBCrLf
message = message & "Coach eMail 4: " & CoacheMail4 & VBCrLf
message = message & "Home Field 4: " & HomeField4 & VBCrLf

message = message & "Age Group 5: " & AgeGroup5 & VBCrLf
message = message & "Coach Name 5: " & CoachName5 & VBCrLf
message = message & "Phone 5: " & Phone5 & VBCrLf
message = message & "Coach eMail 5: " & CoacheMail5 & VBCrLf
message = message & "Home Field 5: " & HomeField5 & VBCrLf

message = message & "Age Group 6: " & AgeGroup6 & VBCrLf
message = message & "Coach Name 6: " & CoachName6 & VBCrLf
message = message & "Phone 6: " & Phone6 & VBCrLf
message = message & "Coach eMail 6: " & CoacheMail6 & VBCrLf
message = message & "Home Field 6: " & HomeField6 & VBCrLf

message = message & "Age Group 7: " & AgeGroup7 & VBCrLf
message = message & "Coach Name 7: " & CoachName7 & VBCrLf
message = message & "Phone 7: " & Phone7 & VBCrLf
message = message & "Coach eMail 7: " & CoacheMail7 & VBCrLf
message = message & "Home Field 7: " & HomeField7 & VBCrLf

message = message & "Club Contact: " & ClubContact & VBCrLf
message = message & "Address 1: " & Address1 & VBCrLf
message = message & "Address 2: " & Address2 & VBCrLf
message = message & "City, St: " & CitySt & VBCrLf
message = message & "Telephone: " & Telephone & VBCrLf
message = message & "eMail: " & eMail & VBCrLf

set smtp = Server.CreateObject("Bamboo.SMTP")
' You only need to change the smtp.Rcpt ans smpt.from part to your email address
smtp.Server = "mail.nwsoccer.net"
smtp.Rcpt = "kgwortman@charter.net"
smtp.From = "webmaster@nwsoccer.net"
smtp.FromName = Request.ServerVariables("HTTP_REFERER")
smtp.Subject = "Seasonal Commitment Form - " & Request.ServerVariables("HTTP_REFERER")
smtp.Message = message
on error resume next
smtp.Send
if err then
response.Write err.Description
else
response.Redirect ("http://www.nwsoccer.net/thankyou.htm")
end if
set smtp = Nothing
%>


The problem is, this does not work when the form submit button is hit. Is my syntax incorrect? I have included every form field in the form.   I am getting desperite.   After several hours, I cannot figure out what is wrong.   If you want to see the form itself, it is located at www.nwsoccer.net/seasonalcommitB1test.htm

Thanks for any help you can provide.

Kevin


Answer
Hello Kevin,

I am going to tell how to debug problems like this, so please do what I say and you cn solve your problem on your own.

Comment all the Messages from the second code and unComment only
----------------
message = message & "Boys Division 1 Only: " & BoysDivision1Only & VBCrLf
message = message & "Season: " & Season & VBCrLf
message = message & "Year: " & Year & VBCrLf
message = message & "Club Name: " & ClubName & VBCrLf
----------------
This part, If still have same problem then
Comment all the code for the "Request" and uncomment only
---------------------
Season = Request.Form("Season")
Year = Request.Form("Year")
ClubName = Request.Form("ClubName")
BoysDivision1Only = Request.Form("BoysDivision1Only")
---------------------

This code and now execute the page. This is the only method you can debug your code and this practice also helps in long run.

Thanks


Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

Email this page
     
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2006 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.