Forum Moderators: coopster & phranque

Message Too Old, No Replies

Problem Viewing perl generated html in outlook

html viewing in outlook

         

chris bowser

4:32 pm on May 4, 2006 (gmt 0)

10+ Year Member



I've been stuck on this problem for some time now. I'm trying to generate an email using perl that contains html coded tables. The tables show up properly when sent to hotmail or gmail, but they lose the formatting when received by outlook. I read a former post that instructed me to place the Content-type: text/html header right before the body of the message, however this didnt solve my problem. any ideas?

perl_diver

5:00 pm on May 4, 2006 (gmt 0)

10+ Year Member



doesn't sound like a perl issue, sounds like on outlook setting might need to be adjusted, but post your perl code if it's not too long.

chris bowser

5:17 pm on May 4, 2006 (gmt 0)

10+ Year Member



The original code has much more to it as it parses a mySQL database to construct the tables. I extracted the email portion of the code and developed a simple table construction here. To throw another twist into the problem, I can email the table to a gmail account and then forward it to my outlook account and have to show up properly, howeve the reverse is not true. It seems to be a problem with the way outlook is interpreting the email. The code i'm posting also contains some additional formatting code that I included after looking at an table I generated using outlook, so I dont think it is needed, but its there.

Code:

use POSIX qw(strftime);
use DBI;
use Net::SMTP;
use MIME::Lite;
use Getopt::Long;

$send_to = 'chris.bowser@mtsallstream.com';

$email.= "<html> \n";
$email.= "<body>Still under test <br>\n";
$email.= "<div class=Section1> \n";

$email.= "<table class=MsoTableColumns2 border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse'> \n";
$email.= "<tr> \n";
$email.= "<td valign=top bgcolor=white style='background:navy;padding:0in 5.4pt 0in 5.4pt'><p class=MsoNormal><b><font size=2 color=white face=Arial><span style='font-size:10.0pt;font-family:Arial;color:white;font-weight:bold'>Heading 1</span></font></b></p> \n";
$email.= "</td> \n";
$email.= "<td valign=top bgcolor=white style='background:navy;padding:0in 5.4pt 0in 5.4pt'><p class=MsoNormal><b><font size=2 color=white face=Arial><span style='font-size:10.0pt;font-family:Arial;color:white;font-weight:bold'>Heading 2</span></font></b></p> \n";
$email.= "</td> \n";
$email.= "</tr> \n";

$email.= "<tr> \n";
$email.= "<td valign=top style='padding:0in 5.4pt 0in 5.4pt'><p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black'>a1 value</span></font></p> \n";
$email.= "</td> \n";
$email.= "<td valign=top style='padding:0in 5.4pt 0in 5.4pt'><p class=MsoNormal><font size=2 color=black face=Arial><span style='font-size:10.0pt;font-family:Arial;color:black'>a2 value</span></font></p> \n";
$email.= "</td> \n";
$email.= "</tr> \n";

$email .="</table></div></body></html> \n";
print("$email");
SendEmail();

sub SendEmail{

#send me an e-mail
#to view information being sent to SMTP server
#$smtp = Net::SMTP->new('smtp_mts.mts.mb.ca',Hello => 'mts.ca',Debug => 1);
$smtp = Net::SMTP->new('smtp_mts.mts.mb.ca',Hello => 'mts.ca');
$smtp->mail("Test_Email");
#create array of Recipients
@RecipientArr = split(/\¦\¦\¦/,$send_to);
$smtp->recipient(@RecipientArr , {SkipBad=>1});
$smtp->data();
$smtp->datasend("From: Mobility Exception Reporting \n");
$smtp->datasend("To: $send_to \n");
$smtp->datasend("Subject: $description \n");
#$smtp->datasend("MIME-Version: 1.0 \n");
$smtp->datasend("Content-Type: text/html; charset=us-ascii \n");
$smtp->datasend("$email");
$smtp->dataend();
$smtp->quit;
$email = ' ';
}#end sub SendEmail