use POSIX qw(tmpnam); use strict; # || loose XP. use Sender; # ? my $tmpfile = tmpnam(); open(OUT, ">$tmpfile") || die("Can't write tmp-file"); print OUT "data ... data ... data\n"; close(OUT); my $sender = Sender new; ## create message with attachment $sender->MailFile({ to => "$username\@mycompany.inc", subject => "$subject", msg => "Attached is the info you need!", file => "$tmpfile", }); unlink $tmpfile;