P
p cooper
I can convert a pipe-delimited file to *.xls and can read it locally using
excel.
I then try to attach it to an email:
at the other end the email comes through with a 0K (empty) attachment with
the correct name.
Im using a defined variable for the path and filename in case it was typos.
In addition running the script from the command line generates no errors
and the message comes through the system.
Run from the browser I get
Can't call method "add_worksheet" on an undefined value
at /home/servers/ais/cgi-bin/excel.pl line 23.
(historical path...)
Not sure if they are related........
#!/usr/bin/perl -w
use CGI qw cgi-lib standard carpout); # Include CGI functions
use CGI::Carp qw(fatalsToBrowser); # Send error messages to browser
use Fcntl ':flock'; # import LOCK_* constants
use strict;
use Spreadsheet::WriteExcel;
use MIME::Lite;
my $path ="/home/paul/";
my $dbfile='db.xls';
my $pathdb=$path.$dbfile;
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new($pathdb);
# Add a worksheet
my $worksheet = $workbook->add_worksheet();
open(FH,"</tmp/results");
my @data=(<FH>);
close (FH);
my $n=1;
foreach my $i (@data)
{
chomp $i;
my @a = split(/\|/, $i);
$array_ref = \@a;
$worksheet->write($n, 0, $array_ref);
$n++;
}
my $message = MIME::Lite->new(
From => '(e-mail address removed)' ,
To => '(e-mail address removed)' ,
Cc =>'(e-mail address removed)',
Subject => "The database file as an Excel format",
Type => "text/plain",
Encoding => '7bit',
Data => "Database file"
);
my ($mime_type, $encoding) = ('application/vnd.ms-excel', 'base64');
$message->attach (
Type => $mime_type ,
Encoding => $encoding ,
Path => $pathdb ,
Filename => 'database.xls'
);
# ----- Tell MIME::Lite to use Net::SMTP instead of sendmail
MIME::Lite->send('smtp', 'smtp.isp.com', Timeout => 20);
$message->send;
excel.
I then try to attach it to an email:
at the other end the email comes through with a 0K (empty) attachment with
the correct name.
Im using a defined variable for the path and filename in case it was typos.
In addition running the script from the command line generates no errors
and the message comes through the system.
Run from the browser I get
Can't call method "add_worksheet" on an undefined value
at /home/servers/ais/cgi-bin/excel.pl line 23.
(historical path...)
Not sure if they are related........
#!/usr/bin/perl -w
use CGI qw cgi-lib standard carpout); # Include CGI functions
use CGI::Carp qw(fatalsToBrowser); # Send error messages to browser
use Fcntl ':flock'; # import LOCK_* constants
use strict;
use Spreadsheet::WriteExcel;
use MIME::Lite;
my $path ="/home/paul/";
my $dbfile='db.xls';
my $pathdb=$path.$dbfile;
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new($pathdb);
# Add a worksheet
my $worksheet = $workbook->add_worksheet();
open(FH,"</tmp/results");
my @data=(<FH>);
close (FH);
my $n=1;
foreach my $i (@data)
{
chomp $i;
my @a = split(/\|/, $i);
$array_ref = \@a;
$worksheet->write($n, 0, $array_ref);
$n++;
}
my $message = MIME::Lite->new(
From => '(e-mail address removed)' ,
To => '(e-mail address removed)' ,
Cc =>'(e-mail address removed)',
Subject => "The database file as an Excel format",
Type => "text/plain",
Encoding => '7bit',
Data => "Database file"
);
my ($mime_type, $encoding) = ('application/vnd.ms-excel', 'base64');
$message->attach (
Type => $mime_type ,
Encoding => $encoding ,
Path => $pathdb ,
Filename => 'database.xls'
);
# ----- Tell MIME::Lite to use Net::SMTP instead of sendmail
MIME::Lite->send('smtp', 'smtp.isp.com', Timeout => 20);
$message->send;