jimbus has asked for the wisdom of the Perl Monks concerning the following question:
Update: This was solved with bart's help. I wasn't closing the file after I generated it. Thanks bart!
Hello, I've got a script that generates an Excel file using Spreadsheet::WriteExcel as well as some graphs with GD::Graph and tries to email them out using Mime:Lite.
The Excel document creates correctly, I can FTP it over and open it correctly, but the document attached to the email, though, is empty. Outlook claims the attachment is 64kb, but when I save it to disk, it is 0kb. The graphs all display in-line and the CSVs I'd been sending just as attachments before the requirements changed worked.
use MIME::Lite; my $msg = MIME::Lite->new( From => 'WirelessDataServices@dobson.net', To => $props->{maillist}, Subject => "Wireless Data Weekly Report for $time\n", Type => 'multipart/mixed' ); $msg->attach(Type => 'text/html', Data => qq{ <img src="cid:sms.gif"><br> <img src="cid:wsb.gif"><br> <img src="cid:mms.gif"><br> <img src="cid:byte.gif"><br> <img src="cid:frate.gif"><br> } ); $msg->attach(Type => 'image/gif', Path => '/usr/local/reports/wds/tims_rept/sms.gif', Id => 'sms.gif', ); $msg->attach(Type => 'image/gif', Path => '/usr/local/reports/wds/tims_rept/wsb.gif', Id => 'wsb.gif', ); $msg->attach(Type => 'image/gif', Path => '/usr/local/reports/wds/tims_rept/mms.gif', Id => 'mms.gif', ); $msg->attach(Type => 'image/gif', Path => '/usr/local/reports/wds/tims_rept/byte.gif', Id => 'byte.gif', ); $msg->attach(Type => 'image/gif', Path => '/usr/local/reports/wds/tims_rept/frate.gif', Id => 'frate.gif', ); $msg->attach(Type => 'application/vnd.ms-excel', Path => '/usr/local/reports/wds/tims_rept/WDS.xls', Id => 'WDS.xls', ); $msg->send('smtp','smtp.dobson.net');
Above is the relavent code... if anyone has any ideas why I can't email this, please let me know... BTW, ls -l on the Path for the offending item shows a file sized 21504.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mime::Lite attach issue
by Anonymous Monk on Mar 12, 2013 at 18:33 UTC |