Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to add html code to format within CFMAIL

New Here ,
Aug 14, 2008 Aug 14, 2008
Hello,
I am a newbie to CFMAIL and like to ask if there is a way to format the output within CFMAIL. I tried to enter HTML code within CFMAIL and I got the html code from output.

I created a simple comments form for users to submit their comments, and send this result to my email.

Here is my code:

<CFMAIL TO = "test@test.com"
FROM = "test@test.com"
SUBJECT = "test"
>

New suggestions: <br />
<b>Name:</b> #name#
<b>Comments:</b> #comments#
</CFMAIL>

On the output, I received all html code and when a user enter multiple rows of suggestions, they are not aligned properly in the email.

How do I format the output within cfmail?
How do I get good format for the comments with multiple rows?

Thanks very much.

Jenny.
2.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 14, 2008 Aug 14, 2008
You need to define TYPE="html" (within the CFMAIL tag), this means your email is sent as html rather than plain text.

Then I would use tables to format the email,setting the width of the email no more than 500px 🙂 I know tables are abit old fashioned but email clients can be difficult to predict and tables seem to delay reliably.

e.g.
<cfoutput>
<h2>New Suggestions:</h2>
<table width="500px">
<tr><td width="100px">Name:</td><td width="400px">#name#</td></tr>
<tr><td>Comments</td><td>#comments#</td></tr>
</table>

etc...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2008 Aug 14, 2008
It worked almost perfectly.
If a user enter in comments box in multiple lines like this:
1. abc
2. testss
3. dsf22

When I viewed the result within email, it does not break down to rows but shows just one line.

Please help.

Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2008 Aug 14, 2008
Try replacing #comments# with:

#replace(paragraphFormat(comments),"<P>","<br /><br />")#
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2008 Aug 14, 2008
I tried exactly what you said but it did not return the separate rows.
Please advice.
thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2008 Aug 14, 2008
One more question, I created a selection drop list for multiple selection which allow users to select more than one option.

<CFSELECT NAME="choice" SIZE="3" multiple="true">
<OPTION>good
<OPTION>bad
<OPTION>Other
</CFSELECT>
When a user select both bad and other, then the output is "bad,other"

How do I remove ',' or 'comma' and replace it with a ' ' or 'space'?

thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2008 Aug 14, 2008
quote:

Originally posted by: jennypretty2
One more question, I created a selection drop list for multiple selection which allow users to select more than one option.

<CFSELECT NAME="choice" SIZE="3" multiple="true">
<OPTION>good
<OPTION>bad
<OPTION>Other
</CFSELECT>
When a user select both bad and other, then the output is "bad,other"

How do I remove ',' or 'comma' and replace it with a ' ' or 'space'?

thanks.


#replace(choice, ',', ' ', 'ALL')#
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2008 Aug 14, 2008
It worked.

Can you please help me with the 'multiple rows' when user enter in separate lines? I like to have result in the same way as the user type in the comment box.

Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 14, 2008 Aug 14, 2008
I'm not sure, but you might be able to set it up so that part of your mail body is html and part is plain text. The from textareas is what you want in plain text.

I've never tried it but I vaguely remember reading something like that on these forums.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2008 Aug 14, 2008
I search on google to see if I can make the 'comments' box to be plain text, but never find this information.
Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 14, 2008 Aug 14, 2008
search on <cfmailparam>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2008 Aug 14, 2008
I did a search for this exact problem, and came upon this site:
http://jennifermadden.com/javascript/stringEscape.html

However this will only help solve your problem on the client side, and it may throw your users off a bit by inserting html into the text box. My original replace statement will insert spaces only if the user enters in two spaces, and will not work for one.

Possibly the best way to get everything to work as needed, would be to setup a wysiwyg editor.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 15, 2008 Aug 15, 2008
It may be more complicated.
thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 15, 2008 Aug 15, 2008
try:
#replace(comments, chr(10), "<br>", "ALL")#

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 15, 2008 Aug 15, 2008
LATEST
Azadi, I tried that one along with chr(13), \n, \r, and \r\n.. still, nothing.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources