#!C:\Perl\bin\perl.exe
# Take output of Data Protector Session and send in an email
use warnings;
use strict;
use MIME::Lite;
use Getopt::Std;
my $file = "output_" . time() . ".html";
open (IN, "omnirpt -report session_objects -session %SESSIONID% -html|") or die "$!";
open(OUT, ">$file") or die "$!";
while (<IN>)
{
print OUT $_ ;
}
close(OUT);
my $SMTP_SERVER = 'mailserver';
my $DEFAULT_SENDER = 'sender@email.com';
my $DEFAULT_RECIPIENT = 'to@email.com';
MIME::Lite->send('smtp', $SMTP_SERVER, Timeout=>60);
my (%o, $msg);
# process options
getopts('hf:t:s:', \%o);
$o{f} ||= $DEFAULT_SENDER;
$o{t} ||= $DEFAULT_RECIPIENT;
$o{s} ||= 'DAILY APPLICATIONS MSL JOB COMPLETE';
# construct and send email
$msg = new MIME::Lite(
From => $o{f},
To => $o{t},
Subject => $o{s},
Data => "Test",
Type => "multipart/mixed",
);
$msg->attach( 'Type' => 'application/octet-stream',
'Encoding' => 'base64',
'Path' => "C:/Program Files/OmniBack/bin/$file",
'Disposition' => 'attachment' );
$msg->send( );
unlink($file);