troubleshooting Question

ASPEmail HTML email content format no carriage returns / line feeds

Avatar of 51501984
51501984Flag for United Kingdom of Great Britain and Northern Ireland asked on
ASP
1 Comment1 Solution315 ViewsLast Modified:
I've just set-up a basic web form in ASPEmail which works well except there is a free text input area (Body) that when it arrives via email is displayed without carriage returns.
Is there some code i can add to the ASP part that will format the HTML email with <br /> instead of the carriage return.
If it was a web page I'd do this:
<%=Replace((Recordset.Fields.Item("FieldName").Value), Chr(13), "<br />")%>
but as it's email and HTML I don't know how to do it. can you help?
<%
' change to address of your own SMTP server
strHost = "X.X.X.X"
 
If Request("Send") <> "" Then
   Set Mail = Server.CreateObject("Persits.MailSender")
   ' enter valid SMTP host
   Mail.Host = strHost
   Mail.Username = "XXXXXXXXXXX"
   Mail.Password = "XXXXXXXXXXX"
   Mail.From = Request("From") ' From address
   Mail.FromName = Request("FromName") ' optional
   Mail.AddAddress Request("To")
   Mail.AddCC Request("From")
 
   ' message subject
   Mail.IsHTML = True
   Mail.Subject = Request("Subject")
   ' message body
     Mail.Body = "<HTML><BODY BGCOLOR=#ccffff  style=font-family:Arial, Helvetica, sans-serif;>" & Request("Subject") & "<br>" & Request("From") & "<br>" & Request("FromName") & "<br>" & Request("Body") & "</BODY></HTML>"
   strErr = ""
   bSuccess = False
   On Error Resume Next ' catch errors
   Mail.Send ' send message
   If Err <> 0 Then ' error occurred
      strErr = Err.Description
   else
      bSuccess = True
      Response.Redirect("wyjs-archaeology-thanks.asp")
   End If
End If
%>
 
<HTML>
<BODY BGCOLOR="#FFFFFF">
<% If strErr <> "" Then %>
<h3>Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Success! Message sent to <% = Request("To") %>.
<% End If %>
<FORM METHOD="POST" ACTION="newmail1.asp">
<TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
 
<TR>
   <TD>From (enter sender's address):</TD>
   <TD><INPUT TYPE="TEXT" NAME="From"></TD>
</TR>
<TR>
   <TD>FromName (optional, enter sender's name):</TD>
   <TD><INPUT TYPE="TEXT" NAME="FromName"></TD>
</TR>
<TR>
   <TD>To: (enter one recipient's address):</TD>
   <TD><INPUT TYPE="TEXT" NAME="To"></TD>
</TR>
<INPUT TYPE="hidden" NAME="Subject" value="Young Consumer of the Year Submission">
<TR>
   <TD>Body:</TD>
   <TD><TEXTAREA NAME="Body"></TEXTAREA></TD>
</TR>
<TR>
   <TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
ASKER CERTIFIED SOLUTION
51501984

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros