SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "simple" paragraph formatting

    Hello!

    I have the below mentioned code that I am using to send a simple html email via ASP. Please do let me know how I could modify the code so that the carriage returns are captured and the paragraphs that are entered within the text area are preserved. I do not need any fancy hmtl formatting - just the paragraphs.

    Thanks in advance!

    Code:
    <%
    
    If request("submit") <> "" THEN
    
        Set objEmail= CreateObject("CDO.Message")
        objEmail.From = Request("from")
        objEmail.To = "Info@mysite.com"
        objEmail.CC = Request("from")
        objEmail.Subject = Request("subject")
       objEmail.HTMLBody = "<table width = 700 align=center border =0>" & _
    	"<tr><td width=200><font face=Arial size=2 color=#000000>Name: </font></td><td width=300><font face=Arial size=2 color=#800000><b>" & Request("Sender_Name") & "</b></font></td></tr>" &_
    	"<tr><td width=200><font face=Arial size=2 color=#000000>Your Email: </font></td><td width=300><font face=Arial size=2 color=#800000><b>" & Request("from") & "</b></font></td></tr>" &_
    	"<tr><td colspan=2><font face=Arial size=2 color=#000000>Comments</td></tr>"&_
    	"<tr><td colspan=2><font face=Arial size=2 color=#000000>" & Request("Sender_comments") & "</font></td></tr>" &_
    	"</table>"
     	
     	objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    	objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mysite.com"
    	objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    	objEmail.Configuration.Fields.Update
        objEmail.Send 
        Set objEmail = Nothing 
    'Enter Thank you message
    Response.Write("<p>Thank you for your comments.<br>We shall follow up shortly.</p>")
    Else
    
    %>

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try replacing:
    Request("Sender_comments")
    with
    Replace(Request("Sender_comments"), vbCrLf, "<br/>")

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up thanks!

    Thank you that worked like a charm!

    I test this by pasting stuff directly from WORD and directly entering text into the memo field - and in both cases the paragraphs were preserved.

    Me and the Users thank you!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •