Forum Moderators: phranque

Message Too Old, No Replies

ASPmail Results Order...

getting form results to appear in the correct order.

         

chowcat

11:08 am on Sep 24, 2002 (gmt 0)



I am currently using ASPmail to process form data to email, but all the results are coming out in a very odd order.

For example NAME: - which is the first field, is coming out 6th in the email, and the same with every other field.

Is there anyway to determine in which order to display the data in an email?

Thanks.

BlobFisk

11:23 am on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this not determined by the order in which you write them in your code? eg:


' build mail body
mailBody = "Form Submission" & vbCr & vbCr
mailBody = mailBody & "Name: " & name & vbCr
mailBody = mailBody & "E-Mail: " & email & vbCr
mailBody = mailBody & "Telephone: " & telephone & vbCr
mailBody = mailBody & "Message: " & message & vbCr

' build email containing submitted information
set mailobj = server.CreateObject("CDONTS.Newmail")
mailobj.From = "me@mydomain.com"
mailobj.To = "me@mydomain.com"
mailobj.Subject = "Form Submission"
mailobj.Body = mailBody
mailobj.Send
set mailobj = nothing

What order are you writing the mailBody variables?

chowcat

11:38 am on Sep 24, 2002 (gmt 0)



In the same order they appear on the form, which is the same order I would like them to appear them in the email results, but it doesn't seem to have any bearing at all on the order in which they arrive?

BlobFisk

1:02 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you post a snippet of your code for us to have a peek at? It may help...

chowcat

1:25 pm on Sep 24, 2002 (gmt 0)



In its most basic form.....straight from my hosting company's knowledge base.


<%
set mailer = server.createobject("SMTPsvg.Mailer")

Mailer.FromName = Request.Form("Surname")
Mailer.FromAddress = Request.Form("Email")
Mailer.RemoteHost = "mail.mydomain.com"
Mailer.AddRecipient "Enquiry", "enquiry@mydomain.com"
Mailer.Subject = "Enquiry"

For each Item in Request.Form ' Loop through each Form item
strMsgInfo = strMsgInfo & Item & ": " & Request.Form(Item) & vbCrLf
next

strMsgHeader = "Form information follows" & vbCrLf & "*************"
strMsgFooter = vbCrLf & "*************"
Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter

if Mailer.SendMail then
' Message sent Ok, redirect to a confirmation page
Response.Redirect ("http://www.mydomain.com/confirmation.html")
else
' Message send failure
Response.Write ("An error has occurred.<BR>")
' Send error message
Response.Write ("The error was " & Mailer.Response)
end if
%>

txbakers

2:01 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I see your problem, sort of. You are using a For loop to loop through the Form elements. Instead of using the loop, just hard code the form elements in the order you want them.

Iguana

2:14 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I had the same problem when I did a For Each loop

try

for i = 1 to Request.Form.Count
Response.write Request.Form.Key(i) & ":" & " " & Request.Form(i)
next

This will bring them out in the order they are on the submission page source

chowcat

2:42 pm on Sep 24, 2002 (gmt 0)



Thanks a lot, will give it a go..