Solved

cfmail formatting - Restore spaces

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

18 Experts available now in Live!

Get 1:1 Help Now