Home: Perl Programming Help: Advanced:
Blank file as Attachment with MIME::LITE



kinny
Novice

Sep 30, 2010, 11:29 AM


Views: 4701
Blank file as Attachment with MIME::LITE

hi Gurus,

Code
use MIME::Lite; 
my $outDir = "C:/" ;
my $outFile = "wkly device rpt "."$today.xls";
my $file = "$outDir"."$outFile";
my $subject = " Weekly Report for $today";
my $msg = "Hi ";
#Open the File for Writing
open (OUTPUT, ">$file") || die print "Cannot open $file\n";
print OUTPUT "FOUNDATION_ACCT_NUM\tORDER_ID\tSTATE\tCREATION_DATE\tLOSGTYPE\tDESCRIPTION\tPRODUCT_ID\tDISPLAY_NAME\tPRODUCT_TYPE\tWIRELESS\#\tPLAN_NAME\n";

my $message = MIME::Lite->new(
From => 'xxx@xxx.com',
To => 'xxxx@xxx.com,xxx@xxx.com',
Subject => $subject,
Data => $msg
);
# add the attachment
$message->attach(
Type => "application/txt",
Path => "$file",
#Filename => "$outFile",
Disposition => "attachment"
);
$message->send('smtp','xxxxx.net', Debug =>1);


This is sending a blank attachment.I see that the file is not blank and is available in C:/.
I am running this on Windows XP.
Can anyone explain and suggest me ways to correct this code.

Thanks in advance,


FishMonger
Veteran / Moderator

Sep 30, 2010, 3:48 PM


Views: 4693
Re: [kinny] Blank file as Attachment with MIME::LITE

Close the file before attaching it to the email.