Scripting question

B

Bonnie

I am working on sending form results to email with ASP
code. I had it working ok until I tried to build the body
of the email. There are several fields on the form and I
want to build the body of the email by showing only the
fields that were filled in by the user (don't show null
ones)

I am doing it like this:

Dim strBody

If Request.Form("Outlook") <> "" Then
strBody = strBody & "Outlook : "
strBody = strBody & Request.Form("Outlook") & Chr(13)
End if

......

And I repeat the IF statements for each field on the form
in order to build the body of the email. For some reason,
it's not working.

Am I coding the IF statements correctly?

Thanks
Bonnie
 
K

Kevin Spencer

Hi Bonnie,

Your If statement looks fine, but that's all I can say about it until you
describe what you mean by "not working".

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
J

Jon Spivey

Hi Bonnie

That code looks fine - what's going wrong?

The way you're doing it is the long way around though - you don't need to
check each field individually you can just loop through all the fields and
add the ones that arent blank, eg

<%
for i = 1 to request.form.count
if request.form.item(i) <> "" then
strBody = strBody & request.form.key(i) & " = " & request.form.item(i) &
vbcrlf
end if
next
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top