Solved

cfmail formatting - Restore spaces

Posted on 2011-09-27
2
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
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.

724 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