Home: Perl Programming Help: Advanced:
Unable to send excel sheet (2 issues)


Oct 13, 2010, 2:52 PM

Views: 3351
Unable to send excel sheet (2 issues)

Hi Gurus,
Two Issues :
1. I have created an excel file with WriteExcel. But I am not able to send it as attachment.The attachment reaches the recipient but it says that the file cannot be accessed or it may be corrupted. But I am able to open the file from its location in my hard disk. Here is the code

my $message = MIME::Lite->new
Subject => 'Reporting Online',
From => 'xxxx@xxx.com',
To => 'xxx@xxx.com',
Type => 'text/html',
Data => $msg
# add the attachment
Type => "text/xls",
Path => "$file",
#Filename => "$outFile",
Disposition => "attachment"
$message->send('smtp','xxx.xx.xx.net', Debug =>1);

2. I am trying to zip the above file and send as attachment but i am not able to zip it. Any idea why? This is what i used
`zip "$file" "$zipFile"`;


Oct 13, 2010, 4:05 PM

Views: 3344
Re: [kinny] Unable to send excel sheet (2 issues)

I found out the issue. The issue was with the type of the attachment . It should have been csv/xls instead of text/xls.However the secound issue persists.Can someone assist on that

In Reply To

(This post was edited by kinny on Oct 13, 2010, 4:06 PM)

Veteran / Moderator

Oct 13, 2010, 4:20 PM

Views: 3341
Re: [kinny] Unable to send excel sheet (2 issues)

You didn't provide enough info for use to determine your zip problem, but instead of using backticks to an external program, it would be better to use the Archive::Zip module.



Oct 13, 2010, 9:19 PM

Views: 3333
Re: [FishMonger] Unable to send excel sheet (2 issues)

Thank You. I just did a bit of googling for the same and came up with the below code. But the code sends a zip with the full path of the file rather than the file alone.
my $file="testFile.xls";
my $zipfile = "C:/xxx/xxx/xxxxxxxxx.zip";
$zip->writeToFileNamed( $zipfile );
This is the path of the zipped file C:\xxx\xxx\xxxxxxxxx.zip\\xxx\xxx\<filename.xls";
I am not able to upload the file and the attachment owing to the confidentiality of the data. Hope this explains.
Thanks fishmonger for your previous replly