CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



kinny
Novice

Oct 13, 2010, 2:52 PM

Post #1 of 4 (1358 views)
Unable to send excel sheet (2 issues) Can't Post

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

Code
$workBook->close(); 
my $message = MIME::Lite->new
(
Subject => 'Reporting Online',
From => 'xxxx@xxx.com',
To => 'xxx@xxx.com',
Type => 'text/html',
Data => $msg
);
# add the attachment
$message->attach(
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"`;


kinny
Novice

Oct 13, 2010, 4:05 PM

Post #2 of 4 (1351 views)
Re: [kinny] Unable to send excel sheet (2 issues) [In reply to] Can't Post

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)


FishMonger
Veteran / Moderator

Oct 13, 2010, 4:20 PM

Post #3 of 4 (1348 views)
Re: [kinny] Unable to send excel sheet (2 issues) [In reply to] Can't Post

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.

http://search.cpan.org/~adamk/Archive-Zip-1.30/lib/Archive/Zip.pm


kinny
Novice

Oct 13, 2010, 9:19 PM

Post #4 of 4 (1340 views)
Re: [FishMonger] Unable to send excel sheet (2 issues) [In reply to] Can't Post

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->addFile("C:/Ax/Dx/x/".$file);
$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

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives