Avatar of 51501984
51501984
Flag for United Kingdom of Great Britain and Northern Ireland asked on

ASPEmail HTML email content format no carriage returns / line feeds

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>

Open in new window

ASP

Avatar of undefined
Last Comment
51501984

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
51501984

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23