PDA

View Full Version : How can I sort the variables to appear in my e-mail?


martijnvandelaa
01-11-2003, 12:32 AM
How can I sort the variables to appear in my e-mail?

Normally I use CGI mailscritps on my websites, but this time the ISP does not support CGI :(, so I have to use ASP. This is something I have never used before. So far everything I did worked well :) accept the order in wich the variables appear in my email. Can I sort this in some way, so that the mail is readable.

This is the code I am using right now:

<%
on error resume next
Set Mailer = Server.CreateObject("CDONTS.NewMail")

MailTo = "****@****"

if request("_from") = "" then
MailFrom = "****@****"
else
MailFrom = request("_from")
end if

if request("_subject") = "" then
Subject = "Offerte aanvraag - Aluminium Ramen"
else
Subject = request("_subject")
end if

Mailer.From = MailFrom
Mailer.To = MailTo
Mailer.Subject = Subject

for each whatever in request.querystring
Message = Message & whatever & "=" & vbcrlf
Message = Message & request.querystring(whatever) & vbcrlf
next

for each whatever in request.form
Message = Message & whatever & "=" & vbcrlf
Message = Message & request.form(whatever) & vbcrlf
next

Mailer.Body = Message
Mailer.Send
Set Mailer = nothing

response.redirect "bedankt_ramen.html"
%>

You can find the form at the following link:
www.i-cre8.nl/marex/contact/formulier_ramen.html

whammy
01-11-2003, 12:44 AM
In order to sort them, you will need to name each variable, instead of using

for each whatever in request.form()
'do something
next

since that will return them out of order...

then you can order them however you want, by variable name.

i.e.

If Request.ServerVariables("REQUEST_METHOD") = "GET" Then
myfirstvariable = Request.QueryString("myfirstvariable")
mysecondvariable = Request.QueryString("mysecondvariable")
ElseIf Request.ServerVariables("REQUEST_METHOD") = "POST" Then
myfirstvariable = Request.Form("myfirstvariable")
mysecondvariable = Request.Form("mysecondvariable")
End If

If myfirstvariable <> "" Then
MyMessage = MyMessage & "My First Variable: " & myfirstvariable & vbCrLf 'The vbCrLf is a line break!
End If


P.S. You don't need to name the "REQUEST_METHOD" since if you just use Request("variablename") it will search all of the request collections to see if that variable exists. But it is a little faster if you do, from what I've heard, since then ASP doesn't have to search the different methods, i.e. "Form","QueryString" etc.

Hope this helps!

:)