If you want to do this real-time, I can't help, but I'd like to see whatever
solution you do come up with.  If you'd be happy to download your data and
mail the results, then perhaps I can help.  I recently faced a similar
problem.  I wrote a script that generates statistics for our proxy server,
and it worked great.  However, my boss wanted me to mail the results to him
as a spreadsheet.  He uses Notes as his E-mail client, Notes insisted on
opening the mail message in-line as text rather than launching Excel,
although I had no problems getting Outlook Express to launch Excel.

The solution I arrived at, with the help of some people on the HP Admin
mailing list, was to store the data as a CSV file and attach it to a mail
message.  The Perl module needed for this is MIME-tools.  MIME-tools uses
IO-stringy and MIME-Base64, but you've probably got MIME-Base64 already since
you're using lwp.

Here's a snippet of code that sends a .csv file as a mail attachment.  I've
only used it on HP-UX.  Clicking on the mail message attachment will launch
Excel from either a Notes or Outlook Express mail client.  The person from
whom I got the original version of this says it works with Outlook mail
clients as well.

#!/usr/local/bin/perl
use MIME::Entity;

#Create some in-line text just for the hell of it.
push @my_message, "This is the data you requested.\n";

# Create an entity.  It's that "multipart/mixed" MIME type that makes
# all the difference to Notes.
$top = build MIME::Entity Type     => 'multipart/mixed',
                          From     => '[EMAIL PROTECTED]',
                          To       => '[EMAIL PROTECTED]',
                          Subject  => "Mail Test";

# Attach the inline text to it:
$top->attach(Data        => \@my_message,
             Type        => 'text/plain',
             Disposition => 'inline',
             Encoding    => 'quoted-printable');

# Now, attach the CSV file as an attachment.  In my production version,
# I have multiple CSV files, so the following is in a loop, and the "Path"
is:
#     $top->attach(Path        => $csv_file,

$top->attach(Path        => './proxy-stats.csv',
             Type        => 'application/octet-stream',
             Disposition => 'attachment',
             Encoding    => 'quoted-printable');

open MAIL, "|/usr/sbin/sendmail -oi -t -odq";     #Pipe for the message.

# Output it:
$top->print(\*MAIL);
close MAIL;

# That's it.  Works great.

----- Original Message -----
From: "Michael A. Chase" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Rajesh Kirpalani" <[EMAIL PROTECTED]>
Sent: Sunday, April 02, 2000 10:39 PM
Subject: Re: How can I use libwww with MSExcel ??


> The easiest way would be to have a script download the quotes (using
libwww)
> and format them into a tab separated field file and load that file into
> Excel.  After you have that working, you might try using Win32::OLE (part
of
> libwin32) or something similar from the Perl script to drive Excel.
> --
> Mac :})


Reply via email to