my $to_email = "xxx\@imail.org"; our $smtp = Net::SMTP->new("smtp.xx.xx.com",Debug=>1); $smtp->mail("xxx\@imail.org"); $smtp->recipient("$to_email"); $smtp->data(); $smtp->datasend("To: $to_email\n"); $smtp->datasend("Cc: xxx\@imail.org\n"); $smtp->datasend("From: xxx\@imail.org\n"); $smtp->datasend("Subject: Annual Access Reviews\n"); $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-Type: multipart/mixed; boundary= \"*BCKTR*\"\n\n"); # Send the body. $smtp->datasend("--*BCKTR*\n"); $smtp->datasend("Content-Type: text/html\n\n"); $smtp->datasend("@$distinct_manager[3], \n\n"); $smtp->datasend("
As a manager your task at hand is the following:
"); $smtp->datasend("

These user access reviews must be completed and returned by 12/18/2015 XX.XX.2015(6).

"); $smtp->datasend("

Please email the completed spreadsheets to emailaddress\@imail.org.

"); $smtp->datasend("

Please go to http://some_internal_website on how to upload your completed spreadsheet(s).

"); $smtp->datasend("
Thank You,
"); $smtp->datasend("
Manager, ISSA Identity and Access Management
"); $smtp->datasend("\n"); $smtp->datasend("--*BCKTR*\n"); $smtp->datasend("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name=\"$attachfile\" \n"); $smtp->datasend("Content-Transfer-Encoding: base64"); $smtp->datasend("Content-Disposition: attachment; filename =\"$attachfile\"\n\n"); $smtp->datasend("\n"); open(DAT, $attachfile) || die("Could not open text file!"); binmode(DAT); my $data = do { local $/; }; close DAT; $smtp->datasend($data); $smtp->datasend("\n"); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit;