Click to See Complete Forum and Search --> : Coding an email message


gcook1
09-19-2005, 09:16 AM
I'm looking for some help on coding an ASP message. I have a form that users will fill out. When they submit it, it sends an email message to the form owner with their input. The current code just puts the answers in a simple list. The form owner is asking me if I can send an email message with HTML imbedded in it to make the form more "readable". Here's the current message code. Any ideas how I can "pretty it up"?

Dim strBody
strBody = "To: " & strMailTo & VbCrLf & _
"Cc: " & strCopyTo & VbCrLf & _
"From: " & strLoginID & "@steelcase.com" & VbCrLf & _
"Date: " & Date & " Time: " & Time & VbCrLf & VbCrLf & _
FORM_NAME & VbCrLf & _
"==================================" & VbCrLf & _
QUESTION1 & Answer1 & VbCrLf & _
QUESTION2 & Answer2 & VbCrLf & _
QUESTION3 & Answer3 & VbCrLf & _
QUESTION4 & Answer4 & VbCrLf & _
QUESTION5 & Answer5

candelbc
09-19-2005, 11:16 AM
Here's some of the code that I use to send an HTML email using CDO. Hopefully this will work for you as well.

Dim CDOMail

Set CDOMail = Server.CreateObject("CDO.Message")
CDOMail.From = strLoginID & "@steelcase.com"
CDOMail.To = strMailTo
CDOMail.Subject = "Email Subject"

sBody = "<span style='font-family: Tahoma, Arial; font-size: 11px;'>"
sBody = sBody & "==[ Feedback ]======================================================================" & "<BR><BR>"
sBody = sBody & "<strong>Employee:</strong> " & Session("user_USERNAME") & "<BR>"
sBody = sBody & "<strong>Date:</strong> " & Now & "<BR><BR>"
sBody = sBody & "<strong>Document Usefulness:</strong> " & optUseful(CInt(Request("optUseful"))) & "<BR>"
sBody = sBody & "<strong>Document Input:</strong> " & optInput(CInt(Request("optInput"))) & "<BR><BR>"
sBody = sBody & "<strong>Additional Notes:</strong> " & "<BR>"
sBody = sBody & Request("txtFeedback") & "<BR><BR>"
sBody = sBody & "===================================================================================" & "<BR><BR>"
sBody = sBody & "</span>"

CDOMail.HTMLBody = sBody
CDOMail.Send

Set CDOMail = Nothing

Bullschmidt
09-20-2005, 01:56 PM
Not all e-mail readers have the setting set to even read HTML e-mails but anyways here is a related link:

E-mail (HTML) Send email messages as lively as a web page.
http://www.asp101.com/samples/email_html.asp