For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > December 2004 > "Pretty" Emails









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author "Pretty" Emails
Mick I Hawkes

2004-12-21, 3:55 am

Hi all,

I am currently using the MIME::Lite module to send Emails,
However my boss wants me to line the tables up better and generally =
pretty it up
A bit (bold) etc.
I can't use HTML as our company is still using NT4 Outlook.
Any ideas on a possible formatting module I can use or any suggestions =
at all=20
Would be much appreciated.


Cheers
Mick H

JupiterHost.Net

2004-12-21, 3:55 am



Hawkes, Mick I wrote:
> Hi all,


Hello,

> I am currently using the MIME::Lite module to send Emails,
> However my boss wants me to line the tables up better and generally pretty it up
> A bit (bold) etc.
>
> I can't use HTML as our company is still using NT4 Outlook.


Your boss wants you to format text without using the world's most
compatible and widely used formatting language??

You can "line up tables better" by formatting your plain text maybe with
printf or sprintf (perldoc -f sprinft and perldoc -f printf) but you
can't make plain text "(bold) etc" without some markup language and
since 99.999999999999 % of mail clients/computers have some form of html
interpreter then html is your best bet.

> Any ideas on a possible formatting module I can use or any suggestions at all


1) Fire your boss, he sounds kinda dumb :)

2) forget using anything else besides html to really format your
messages, anything else will be plain text or some formatting that is
not usable by 99.999999999% of mail clients

3) Kick your boss in the shin's for being so lame

4) send him to http://google.com/search?q=What+is+an+email and he will
find that an email is a bunch of plain text that is formatted into a
header and body section with the body section containing (except for
morons that send html only emails) a plain text part, maybe an html
part, and attached files, if any, encoded in base64

5) Here's a gem: use Mail::Sender its way sexxy and lets you do plain
text and html parts and attachments very very easy, just my .02

HTH :)

Lee.M - JupiterHost.Net
Chris Devers

2004-12-21, 3:57 pm

On Mon, 20 Dec 2004, JupiterHost.Net wrote:

> Hawkes, Mick I wrote:
>
>
> Your boss wants you to format text without using the world's most
> compatible and widely used formatting language??


....which should never, ever have been added to email.

This is offtopic, but let's be honest, HTML is a lousy formatting
language, and adding it to email caused all kinds of problems, from
myriad security issues that never existed before, to enabling spammers
to keep track of who is reading their nocturnal emissions.

Any company that, as a policy, wants to ban HTML mail is okay by me.

So. Text formatting options.

* Use Perl's built-in functionality. This article takes a look at how
this is done today with Perl5, and how it will be done in the future
with Perl6:

<http://www.perl.com/pub/a/2004/02/27/exegesis7.html>

* Use the Text::Template module, if it isn't overkill:

<http://search.cpan.org/dist/Text-Te...ext/Template.pm>

These approaches can handle basic table layouts, but not text styling:
boldface, italics, etc. *But*, some people can _make do_ /without/ that
with text tricks that approximate *bold*, /italics/, and _underlining_.
(I think Word will even take that and apply the actual styles, but I
don't use Word because of such "helpful" things. Some people like it.)

If you really need that kind of formatting, consider using either
attachments (a good PDF will look better than HTML anyway, but you can
also just attach an Office document or whatever) or set up an intranet
server where people can post documents and send each other URLs to them.


--
Chris Devers
JupiterHost.Net

2004-12-21, 3:57 pm

>>Your boss wants you to format text without using the world's most
>
>
> ...which should never, ever have been added to email.


Good point :)

> This is offtopic, but let's be honest, HTML is a lousy formatting
> language, and adding it to email caused all kinds of problems, from
> myriad security issues that never existed before, to enabling spammers
> to keep track of who is reading their nocturnal emissions.
>


> Any company that, as a policy, wants to ban HTML mail is okay by me.


I agree 100%, my beef was with wanting bold etc without using html or
other ML.

> So. Text formatting options.
>
> * Use Perl's built-in functionality. This article takes a look at how
> this is done today with Perl5, and how it will be done in the future
> with Perl6:
>
> <http://www.perl.com/pub/a/2004/02/27/exegesis7.html>
>
> * Use the Text::Template module, if it isn't overkill:
>
> <http://search.cpan.org/dist/Text-Te...ext/Template.pm>
>
> These approaches can handle basic table layouts, but not text styling:
> boldface, italics, etc. *But*, some people can _make do_ /without/ that
> with text tricks that approximate *bold*, /italics/, and _underlining_.
> (I think Word will even take that and apply the actual styles, but I
> don't use Word because of such "helpful" things. Some people like it.)


Good ideas! In my experience most bosses/users are to clueless to use
even such a simple Markup language as the */ and _

> If you really need that kind of formatting, consider using either
> attachments (a good PDF will look better than HTML anyway, but you can


I think the document sharing idea is probably the way to go, generate a
pdf and email it as an aattachment, then it can look as pretty as you
want, will look the exact same for everyone, *and* some mail clients
will display pdfs inline so they may not even need to open it, which
would be (I think Mozilla's mail client and Mac's Mail do this).

(I do this with certain contracts and legal docs, generate the html for
them with their custom content and create a pdf out of that html code
with Perl using htmldoc, there are other modules available to make pdf's
just never tried them ;p)

> also just attach an Office document or whatever) or set up an intranet
> server where people can post documents and send each other URLs to them.

Mick I Hawkes

2004-12-22, 3:56 am

Thanks Chris,
Went to the exegesis7 link and that format will do though I do have some =
questions about it
(I am a newbie to Perl after all :-))

from the site

So, whereas in Perl 5 we might write:

# Perl 5 code...

our ($name, $age, $ID, $comments);

format STDOUT
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
| NAME | AGE | ID NUMBER |
|----------+------------+-----------|
| @<<<<<<< | @||||||||| | @>>>>>>>> |
$name, $age, $ID,
=
|=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D|
| COMMENTS |
|-----------------------------------|
| ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |~~
$comments,
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
John W. Krahn

2004-12-22, 8:57 am

Hawkes, Mick I wrote:
> Went to the exegesis7 link and that format will do though I do have some questions about it
> (I am a newbie to Perl after all :-))
>
> from the site
>
> So, whereas in Perl 5 we might write:
>
> # Perl 5 code...
>
> our ($name, $age, $ID, $comments);
>
> format STDOUT
> ===================================
> | NAME | AGE | ID NUMBER |
> |----------+------------+-----------|
> | @<<<<<<< | @||||||||| | @>>>>>>>> |
> $name, $age, $ID,
> |===================================|
> | COMMENTS |
> |-----------------------------------|
> | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |~~
> $comments,
> ===================================
> .
>
> write STDOUT;
>
> how do I convert this from writing to STOUT to writing to a string. Is it just
> format $mystring ?
>
> up until now I have only been using \t and \n. I have no clue what Q<|^ and ~ do!


perldoc perlform


John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com