Solved

cfmail formatting - Restore spaces

Posted on 2011-09-27
2
313 Views
Last Modified: 2012-05-12
Hi,

I am trying to restore the spaces from a textarea.

Say in a text area the user enters:

Attached are the reports with detailed results of the abc from September 20-21, 2011.  If you are unable to access the reports or have any further questions, please contact me at blah blah.

Thank you.

ABC CDE
123-456-7891
abc@abc.com

I am storing the value of this in a session variable #session.messagebody#

Using the below code the output in the email shows:

 
Attached are the reports with detailed results of the abc from September 20-21, 2011.  If you are unable to access the reports or have any further questions, please contact me at blah blah.
 
Thank you.
 
ABC CDE
123-456-7891
abc@abc.com


I want to restore spacing and the formatting.

<cfset bodyText = REReplaceNoCase(#session.messagebody#,"<a .*(href=['""]?)([^'"" ]+)['"" ][^>]+>([^<]+)</a>","\3: \2","all") >
<cfset bodyText = REReplaceNoCase(bodyText,"<p[^>]*>",Chr(10),"all") >
<cfset bodyText = REReplaceNoCase(bodyText,"<[^>]+>","","all") >

<CFPROCESSINGDIRECTIVE SUPPRESSWHITESPACE="No">  
<CFMAIL
  SUBJECT="#session.Subject#"
  FROM="#session.user_email#"
  TO="#session.ToAddress#"
  cc="#session.CCAddress#"
  bcc="urwebops@bcbsm.com" type="html"
  >
 <p>
<cfoutput>#bodyText#</cfoutput>
 </p>
 
</CFMAIL>
</CFPROCESSINGDIRECTIVE>

Open in new window

0
Comment
Question by:e126614
2 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 36710828

looks like you are replacing the <p> paragraph tag with a line feed.  If this is windows, you need both the line feed and carriage return character.

<cfset bodyText = REReplaceNoCase(bodyText,"<p[^>]*>",Chr(10),"all") >

To this...
<cfset bodyText = REReplaceNoCase(bodyText,"<p[^>]*>",Chr(10)&chr(13),"all") >

But your cfmail is using HTML format, so why are you removing the paragraph markers to be begin with?  Why not just leave them..

If you're going to keep the HTML format, then you can replace them with an HTML line break

<cfset bodyText = REReplaceNoCase(bodyText,"<p[^>]*>","<br>","all") >

0
 

Author Closing Comment

by:e126614
ID: 36711118
Thanks much. :)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question