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.


--Jimbus aka Jim Babcock
Wireless Data Engineer and Geek Wannabe
jim-dot-babcock-at-usa-dot-com

In reply to Mime::Lite attach issue by jimbus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.