J
J.D. Baldwin
I am trying to use a module to send an RTF email (because I need to
use color codes) from Perl. I have been using MIME::Lite to send
email attachments, but am unable to get it to send the mail itself as
RTF. I found a FAQ (not a newsgroup one) on sending HTML email:
http://www.cyberciti.biz/faq/how-do-i-send-html-email-from-perl/
and that works OK, but extrapolating their method to RTF fails. Here
is their suggestion for HTML email:
#!/usr/bin/perl -w
use strict;
use MIME::Lite;
# SendTo email id
my $email = '(e-mail address removed)';
# create a new MIME Lite based email
my $msg = MIME::Lite->new
(
Subject => 'HTML email test',
From => '(e-mail address removed)',
To => $email,
Type => 'text/html',
Data => '<H1>Hello</H1><br>This is a test email.
Please visit our site <a href="http://cyberciti.biz/">online</a><hr>'
);
$msg->send();
As noted, this works fine. If I change this to
#!/usr/bin/perl -w
use strict;
use MIME::Lite;
use RTF::Writer;
my $rtfstring;
my $rtf = RTF::Writer->new_to_string(\$rtfstring);
$rtf->prolog;
$rtf->printf( \'{\pard\cf1');
$rtf->printf( \'Hello, World');
$rtf->printf( \'\par}');
$rtf->close;
my $msg = MIME::Lite->new(
Subject => 'TEST RTF MESSAGE',
From => '(e-mail address removed)',
To => $email,
Type => 'text/rtf',
Data => $rtfstring
);
$msg->send;
.... it simply doesn't work. The "raw" RTF shows up as plain text in
the email.
If anyone has any ideas along these lines, I would appreciate hearing them.
use color codes) from Perl. I have been using MIME::Lite to send
email attachments, but am unable to get it to send the mail itself as
RTF. I found a FAQ (not a newsgroup one) on sending HTML email:
http://www.cyberciti.biz/faq/how-do-i-send-html-email-from-perl/
and that works OK, but extrapolating their method to RTF fails. Here
is their suggestion for HTML email:
#!/usr/bin/perl -w
use strict;
use MIME::Lite;
# SendTo email id
my $email = '(e-mail address removed)';
# create a new MIME Lite based email
my $msg = MIME::Lite->new
(
Subject => 'HTML email test',
From => '(e-mail address removed)',
To => $email,
Type => 'text/html',
Data => '<H1>Hello</H1><br>This is a test email.
Please visit our site <a href="http://cyberciti.biz/">online</a><hr>'
);
$msg->send();
As noted, this works fine. If I change this to
#!/usr/bin/perl -w
use strict;
use MIME::Lite;
use RTF::Writer;
my $rtfstring;
my $rtf = RTF::Writer->new_to_string(\$rtfstring);
$rtf->prolog;
$rtf->printf( \'{\pard\cf1');
$rtf->printf( \'Hello, World');
$rtf->printf( \'\par}');
$rtf->close;
my $msg = MIME::Lite->new(
Subject => 'TEST RTF MESSAGE',
From => '(e-mail address removed)',
To => $email,
Type => 'text/rtf',
Data => $rtfstring
);
$msg->send;
.... it simply doesn't work. The "raw" RTF shows up as plain text in
the email.
If anyone has any ideas along these lines, I would appreciate hearing them.