How do you add HTML and Plain Text to an email?

General question about the package, problems, solutions
DRMartin
Posts: 3
Joined: Wed Feb 04, 2015 12:34 pm

How do you add HTML and Plain Text to an email?

Postby DRMartin » Wed Feb 04, 2015 12:44 pm

I am trying to create email notifications that use HTML formatting, but also allow plain text to be displayed.

I am using the Msg_Header: Content-Type: text/html; charset=us-ascii, which enables the HTML piece.
The problem is then overriding this to allow sections of the message to display plain text.

I found the following solution:
<td><textarea style="border:none; font-family:Calibri" rows="6" cols="100">$Change_Description</textarea></td>

This displays plain text in all browsers from an .htm file, but does not work with an actual email.
Any ideas on how to display the plain text within HTML would be AWESOME!

Cheers

Pavel
Posts: 281
Joined: Fri Dec 12, 2008 12:19 am

Re: How do you add HTML and Plain Text to an email?

Postby Pavel » Wed Feb 04, 2015 12:55 pm

Hi,

You should be able to enclose text within a "PRE" block, i.e.

Code: Select all

<HTML>
...
html document
...

<PRE>
preformatted text
 text
 text
...
</PRE>

</HTML>



Thank you,
Pavel

DRMartin
Posts: 3
Joined: Wed Feb 04, 2015 12:34 pm

Re: How do you add HTML and Plain Text to an email?

Postby DRMartin » Wed Feb 04, 2015 2:12 pm

Thanks Pavel, this helps, but it doesn't maintain (bullets) or (') ... any ideas?

Pavel
Posts: 281
Joined: Fri Dec 12, 2008 12:19 am

Re: How do you add HTML and Plain Text to an email?

Postby Pavel » Wed Feb 04, 2015 3:20 pm

DRMartin wrote:Thanks Pavel, this helps, but it doesn't maintain (bullets) or (') ... any ideas?

You still need to escape special characters within the "pre" tags.
For instance, you can create a user-defined function and use HTML::Entities::encode_entities() function there.

DRMartin
Posts: 3
Joined: Wed Feb 04, 2015 12:34 pm

Re: How do you add HTML and Plain Text to an email?

Postby DRMartin » Wed Feb 04, 2015 4:55 pm

Pavel, sorry I am unfamiliar with this.
Long story short, how do I keep a plain text list from changing?
Data Example:
"Yadda Yadda,
• This update does stuff
• This update doesn't do stuff
• This update needs a miracle"

The <PRE> email looks like this:
"Yadda Yadda,
? This update does stuff
? This update doesn?t do stuff
? This update needs a miracle"

Pavel
Posts: 281
Joined: Fri Dec 12, 2008 12:19 am

Re: How do you add HTML and Plain Text to an email?

Postby Pavel » Wed Feb 04, 2015 5:19 pm

For instance, you would like to include text, contained in "field_name" into email notification body.

1. create user defined function to escape special characters in HTML:
submit udb_property record with
Name: RT_HTML_Escape_Characters
Value:

Code: Select all

require 'HTML/Entities.pm';
return HTML::Entities::encode_entities($_[0]);


2. include the field in the email notification rule body using function defined above to escape special characters

Code: Select all

...
<PRE>
RT_HTML_Escape_Characters($field_name)
</PRE>
...


Return to “Email Notification Package Q&A”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

cron