Help w/ syntax to have body of email include form fields

J

JNariss

Hello,

I finally figured out how to get my form to its database and have an
email come my way. However I am now trying to set up the body of the
email to include the form details. However the body of the email that
is sent only includes the last line of the "body" tag and has no
details next to it.

The email sent shows up with this in its body:

Request Date:


AND NOTHING ELSE.


The script/code I am using is:

<%
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "New Form"
objMessage.Sender = "Intranet"
objMessage.To = "(e-mail address removed)"
objMessage.TextBody="An IT Employee Status Change form has been filled
out. Please see the information below: " & VbCrLf
objMessage.TextBody="Employee Name: " & Request.Form("EmployeeName") &
VbCrLf
objMessage.TextBody="Pay Number: " & Request.Form("PayNumber") & VbCrLF

objMessage.TextBody="Requested By: " & Request.Form("RequestedBy") &
VbCrLF
objMessage.TextBody="Request Date: " & Request.Form("RequestDate")


objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")

= 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")

= "155.116.12.19"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")

= 25
objMessage.Configuration.Fields.Update


objMessage.Send
%>

I am trying to get the body of the email to look like this:

An IT Employee Status Change form has been filled out. Please see the
information below:

Employee Name: Someones Name
Pay Number: XX333
Requested By: Someones Name
Request Date: mm/dd/yy


All the above fields are the fields to my form that users will be
filling out.

Any help would be greatly appreciated.

Thanks,
Justine
 
R

Ray Costanzo [MVP]

This is happening because every time you are assigning a value to the
..TextBody property of your mail object, it's overwriting the previous value.
It's like doing:

Dim x
x = "a"
x = "b"
x = "c"
x = "d"
Response.Write x

What will you get? abcd or d? The answer is d.

Try:

Dim sBody

sBody = = "An IT Employee Status Change form has been filled out. Please see
the information below: " & VbCrLf
sBody = sBody & "Employee Name: " & Request.Form("EmployeeName") & VbCrLf
sBody = sBody & "Pay Number: " & Request.Form("PayNumber") & VbCrLF
sBody = sBody & "Requested By: " & Request.Form("RequestedBy") & VbCrLF
sBody = sBody & "Request Date: " & Request.Form("RequestDate")

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "New Form"
objMessage.Sender = "Intranet"
objMessage.To = "(e-mail address removed)"
objMessage.Textbody = sBody
''etc.

Ray at home
 
J

JNariss

This is exactly what I needed and I thanks for the reasoning behind it,
too. I will try it out and see what happens.

- Justine
 

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

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top