sub EmailClient { my ($file, $dir, $list) = @_; my $msg; my $cover; my @list; my $data; my $bf; my $type; # 9/6/01 $today = `date '+%m/%d/%y'`; $today =~ s/\n//; $cover = "The email body message Thank you, Corporation, Inc."; ### Create a new multipart message: $msg = MIME::Lite->new( From =>'My address ', To =>'robert@idi.net', Subject =>"Your Message", Type =>'text/plain', Data =>"$cover" ); ### Add parts (each "attach" has same arguments as "new") # Attach the HTML document if the email is not empty # Compress and attach the files # $list is a comma separated string of filenames like this: # file1,file2,file3,....fileN @list = split (/,/, $list); foreach $bf (@list) { undef $/; open (ATTACH, "$dir/$bf") || die "Cant open file $dir/$bf\n\n"; $data = ; close (ATTACH); # If file is an HTML file, set type to text/html # If it is an XML file, set type to text/plain if ($bf =~ /\.xml/i) { $type = 'text/plain'; } else { $type = 'text/html'; } $msg->attach ( Type =>"$type", Disposition =>'attach', Data =>"$data", Filename =>"$bf" ); } # Send the message $msg->send(); }