I think, from looking at some of my stored emails with notepad, so I can see the html, that what you need is this:


<x-html>

in front of the html tag, like so:

<x-html><html>

That's a guess but easy enough to test.

ms


From: "Frank Pikelner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: sending email in HTML format
X-Mailer: Microsoft Outlook, Build 10.0.4510
Importance: Normal
X-Authentication-Info: Submitted using SMTP AUTH LOGIN at fep03-mail.bloor.is.net.cable.rogers.com from [24.112.118.191] using ID <[EMAIL PROTECTED]> at Thu, 23 Oct 2003 15:32:53 -0400
X-PMX-Version: 4.0.1.69468
Sender: [EMAIL PROTECTED]
X-BeenThere: [EMAIL PROTECTED]
X-Mailman-Version: 2.0.5
List-Unsubscribe: <http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users>,


<mailto:[EMAIL PROTECTED]>
List-Id: Discussions relating to ActivePerl on Win32 platforms <perl-win32-users.listserv.ActiveState.com>
List-Post: <mailto:[EMAIL PROTECTED]>
List-Help: <mailto:[EMAIL PROTECTED]>
List-Subscribe: <http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users>,


<mailto:[EMAIL PROTECTED]>
List-Archive: <http://mailarchive.activestate.com/browse/perl-win32-users/>
Date: Thu, 23 Oct 2003 15:32:53 -0400
X-Note: This E-mail was scanned for spam.
X-RCPT-TO: <[EMAIL PROTECTED]>

Hello,

I need to write a short Perl program that will send email containing an HTML table with data. My script succeeds sending on the the email, but the HTML does not get interpreted by the client as HTML and appears as HTML tags with the data. My guess is it is something with the HTML that needs to tell the client to interpret the HTML and not display as text. Here is the code I use:


# *** MODULES *** use Socket; use Sys::Hostname; use Net::SMTP; use Win32::OLE qw(in with);


print ("$host");


# *** CONSTANTS ***
   my %detectedErrorState = (
      "0"               => [ "Unknown" ],
      "1"               => [ "Other" ],
      "2"               => [ "No error" ],
      "3"               => [ "Low paper" ],
      "4"               => [ "No paper" ],
      "5"               => [ "Low toner" ],
      "6"               => [ "No toner" ],
      "7"               => [ "Door open" ],
      "8"               => [ "Jammed" ],
      "9"               => [ "Offline" ],
      "10"              => [ "Service requested" ],
      "11"              => [ "Output bin full" ]);

   my %Status = (
      "1"               => [ "Other" ],
      "2"               => [ "Unknown" ],
      "3"               => [ "Idle" ],
      "4"               => [ "Printing" ],
      "5"               => [ "Warmup" ],
      "6"               => [ "Stopped printing" ],
      "7"               => [ "Offline" ]);


# *** VARIABLES *** my $count = 0; my $smtp_host = 'mail.------.com'; my $from = 'me.------.com'; my @to = ('fun.----.com','test.----.com'); my $subject = ''; #my $header = "Please review the following printing items:\n\n"; my $header = ""; my $message = ""; my $host = hostname();

# *** MAIN ***
$header = "\n\n\n<html><head><h1>PRINTER TEST</h1></head><body><table>";
$message = $header . $message;
$message = $message . "<tr><td>PRINTER</td><td>JOBS</td><td>MESSAGE</td><td>STATUS</td><td>MODEL</td></tr>";
&hw_inv;
$message = $message . "</table></body></html>\n\n\n";
if ($count > 0) {
&SendEmail;
}
else {
print ("$printer_server: ($count) Printer Alerts. Done.\n");
}
exit(0);
# *** END MAIN ***



# *** SUB SENDMAIL *** sub SendEmail { my $smtp; if ( $smtp = new Net::SMTP( $smtp_host ) ) { $smtp -> mail( $from ); $smtp -> to( @to ); $smtp -> data(); $smtp -> datasend("To: $to\n"); $smtp -> datasend("Subject: $subject\n"); $smtp -> datasend("\n"); $smtp -> datasend("$message\n"); $smtp -> datasend(); $smtp -> quit(); print("Success: Sent message to @to\n"); print("$subject\n"); } else { print("Failed: send message to @to\n"); } } # *** END SENDMAIL ***


# *** SUB HW_INV ***
sub hw_inv {
# Gather Printer Status
$WMI = Win32::OLE->new('WbemScripting.SWbemLocator') || die "Cannot access WMI on local server: ", Win32::OLE->LastError;
$Services = $WMI->ConnectServer($host) || die "Cannot access WMI on remote machine: ", Win32::OLE->LastError;
# Gather Computer System Information
$printer_set = $Services->InstancesOf("Win32_Printer");
foreach $printer (in($printer_set)) {
$printer_name = $printer->{'Caption'};
$printer_desc = $printer->{'Description'};
$printer_error = $printer->{'DetectedErrorState'};
$printer_driver = $printer->{'DriverName'};
$printer_jobs = $printer->{'JobCountSinceLastReset'};
$printer_location = $printer->{'Location'};
$printer_state = $printer->{'PrinterState'};
$printer_status = $printer->{'PrinterStatus'};
$printer_stat = $printer->{'Status'};
$printer_server = $printer->{'SystemName'};


if ($printer_error != 0) {
$count++;
#$message = $message . "$printer_name\t$printer_jobs\t\t$detectedErrorState{$printer_error}[0]\t\t$Status{$printer_status}[0]\t\t\t$printer_driver\n";
$message = $message . "<tr><td>$printer_name</td><td>$printer_jobs</td><td>$detectedErrorState{$printer_error}[0]</td><td>$Status{$printer_status}[0]</td><td>$printer_driver</td></tr>";
}
if (($printer_error == 0) && ($printer_status == 1)) {
$count++;
#$message = $message . "$printer_name\t$printer_jobs\t\t$detectedErrorState{$printer_error}[0]\t\t$Status{$printer_status}[0]\t\t\t$printer_driver\n";
$message = $message . "<tr><td>$printer_name</td><td>$printer_jobs</td><td>$detectedErrorState{$printer_error}[0]</td><td>$Status{$printer_status}[0]</td><td>$printer_driver</td></tr>";
}


   }
   $subject = "$printer_server: ($count) Printer Alerts";
}
# *** END HW_INV ***


Frank Pikelner [EMAIL PROTECTED]



_______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to