View Single Post
Old Dec 2nd, 2005, 1:33 PM   #2
eclipsed4utoo
Newbie
 
Join Date: Dec 2005
Posts: 7
Rep Power: 0 eclipsed4utoo is on a distinguished road
well, since I can't edit my previous post(that's strange), i will post the code here...

hopefully the indents show up correctly...if not, sorry
#!/usr/bin/perl

use Time::Local;
use MIME::Lite;

# Get the current date 
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time); 
$mymonth = $Month + 1;
$myyear = $Year + 1900;

# the export file from ACL uses a two-digit day.  this adds a '0' if the day is 1-9
if($Day == '1' or $Day == '2' or $Day == '3' or $Day == '4' or $Day == '5' or $Day == '6' or $Day == '7' or $Day == '8' or $Day == '9'){
	$myday = '0' . $Day;
}

$todaysdate = "$mymonth-$myday-$myyear";

$datadir = "C:\\Perl\\";

$datafileSuppliServ = "$todaysdate  SuppliServ_Check_Run_Dups.csv";

$pathSuppliServ = $datadir . $datafileSuppliServ;

if(-e $pathSuppliServ){
	emailSuppliServ();
}

sub emailSuppliServ{
$emailto = 'email@here.com';
$emailstr = "<HTML><BODY><FONT FACE=\"Verdana, Arial, Serif\" SIZE=\"2\">blah blah blah";
$smtp = MIME::Lite->new(
From	=>'email@here.com, To	=> $emailto,
Subject	=>"Check Run file for SuppliServ - $todaysdate", Type	=>'TEXT/html', Data	=>"$emailstr"
) or die "Error creating container. $!\n";

$email_server = "emailserver";
$smtp->attach(Type	=>"text", Path	=>$pathSuppliServ,
	Filename	=>$datafileSuppliServ, Disposition	=>"attachment"
	) or die "Error attaching file. $!\n";

$smtp->send("smtp",$email_server) or die "Error sending mail. $!\n";
}
eclipsed4utoo is offline   Reply With Quote