sub SendEmail { my $file = shift; my $mailTo = shift; my $top = MIME::Entity->build(Type => "multipart/mixed", To => $mailTo, Subject => "test"); $top->attach(Path => $file, Type => 'application/vnd.ms-excel', Disposition => 'attachment') or die "Problem attaching $file: $!"; $top->smtpsend; }