Solved

cfmail formatting - Restore spaces

Posted on 2011-09-27
2
315 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

726 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