Search Persits Software Knowledge Base


Article PS01070360

HOWTO: Including various form items in a message body


This article demonstrates how to include various user-specified form items in the body of an email message sent by AspEmail.


The idea is to concatenate the text items into a single string and assign this string to the Mail.Body property.

For example, a user is asked to fill out the following HTML form and press Submit:

Your name:
Your phone:
Your email:
Which brand interests you:

The content of the form is then sent via email to a sales representative for processing.

The HTML file may look like this:

<TR><TD>Your name:</TD><TD><INPUT TYPE="TEXT" NAME="user_name"></TD></TR>
<TR><TD>Your phone:</TD><TD><INPUT TYPE="TEXT" NAME="user_phone"></TD></TR>
<TR><TD>Your email:</TD><TD><INPUT TYPE="TEXT" NAME="user_email"></TD></TR>
<TR><TD>Which brand interests you:</TD><TD>
  <SELECT NAME="user_brand">
    <OPTION>Patek Philippe</OPTION>
<TR><TD>Comments:</TD><TD><TEXTAREA NAME="user_comments"></TEXTAREA></TD></TR>

The underlying ASP script send.asp may look like this:

Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "" ' specify valid SMTP host
Mail.From = "" ' From address
Mail.FromName = "Sales" ' Optional: From name

Mail.AddAddress ""

' Build message body
Body = "Name: " & Request("user_name") & chr(13) & chr(10)
Body = Body & "Phone: " & Request("user_phone") & chr(13) & chr(10)
Body = Body & "Email: " & Request("user_email") & chr(13) & chr(10)
Body = Body & "Brand: " & Request("user_brand") & chr(13) & chr(10)
Body = Body & "Comments: " & Request("user_comments") & chr(13) & chr(10)

Mail.Body = Body ' assign string to Mail.Body


Note that we use the & operator to concatenate various text items together, and use the combination chr(13) & chr(10) (CR/LF) as a line separator.

Created: 2/8/2002 4:31:14 AM
Last Modified: 2/9/2002 4:11:02 PM

Copyright © Persits Software, Inc. 1998 - 2023
For technical support, write to