> joe wrote:
> > The perl program actually generates three seperate files and one of them
> > happens to be empty. The email that is sent attaches all of the files
to
> > the same email and then sends them out. The user receiving the file is
only
> > receiving the two files with data in them.
>
> Trim the posts you are replying to - esp the sig part.
> Do not top post - reply after the pertinent sentence.
> Do not CC me - I read the list.
>
> Do show some failing code - we can't read your mind (strip your
> script down to the smallest failing code snippet). Just telling
> us your code fails isn't going to get you fixed.
Sorry about that I just got lazy. Here is the snipet of code that reads a
specified directory and attaches the contents to the email.
sub email_files {
opendir(DIR,$str_dir_temp)
|| die("Cannot open directory !\n");
my @dir_contents= readdir(DIR);
closedir(DIR);
if (@dir_contents) {
my ($msg, $mail_att_file);
$msg = MIME::Lite->new (
From => $mail_from_address,
To => $mail_to_address,
Subject => $mail_subject,
Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";
$msg->attach (
Type => 'TEXT',
Data => $mail_message_body
) or die "Error adding the text message part: $!\n";
foreach my $str_file (@dir_contents) {
if (substr($str_file,0,2) eq $strCompCode) {
$msg->attach (
Type => 'TEXT',
Path => $str_dir_temp.$str_file,
Filename => $str_file,
Disposition => 'attachment'
) or die "Error adding $mail_att_file: $!\n";
}
}
# Send the message
MIME::Lite->send('smtp', $mail_host, Timeout=>60);
$msg->send;
}
}
The above scripts works to a degree since it does grab all files that have
something in them and sends them correctly to the recipient. The problem
files are the one that are empty.
> > On Tue, 24 Aug 2004 09:36:12 -0700, $Bill Luebkert wrote
> >
> >>joe wrote:
> >>
> >>
> >>>I have a Perl script that grabs a list of files from a directory and
> >
> > emails
> >
> >>>them to a user. The problem is that I have to email the files
> >
> > regardless of
> >
> >>>size, but for some reason any file that does not have any contents will
> >
> > not
> >
> >>>attach and email.
> >>
> >>Works for me (XP Pro). Tried it both explicitly setting length and not.
> >>Are you sure the file is readable ?
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs