Solved

cfmail formatting - Restore spaces

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now