Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send email through subroutine before Expiration Date 1

Status
Not open for further replies.

duckiebear

Programmer
May 25, 2004
32
0
0
US
I want to modify a current subroutine to send an email to a user 14 days before their contract expiration date ends. I'm not exactly sure how to do this. I have some code to build from that I have tried to modify, but am really at a loss as to what it should really look like. Can anyone help?
Code:
[b]sub notify_users[/b]

local ($local_email_address, $local_comment, $local_mail_template, $local_url) = @_;

$notification_date = $expiration_date - 14)
if $current_date = $notification_date
foreach $email_address (split (/\:/, $local_email_address)) {

$pid_index++;

if ($email_address ne "none") {

  $local_comment =~ s/\#//g;

  `sed 's%<record_number>%${record_number%g;s#<company_name#${company_name}#g;s#<last_name>#${last_name#g;s#<expiration_date>#${expiration_date}#g;s#<comment>#g;s#<local_comment>#g;' $local_mail_template > /home/Mail/inbox/$$.${pid_index}.message_body`;

  if (-z "/home/Mail/inbox/$$.${pid_index}.message_body) {

     `echo "Email Address: $email_address\nRemote Address: $remote_addr\nProgram: contract_tracking.perl\nEmpty email message!" | /usr/sbin/SMIMail -s "No Internet Mailbox found" admin\@emailaddy.com`;

  } else {
     `echo "/home/Mail/inbox/$$.${pid_index}.message_body|Contract Tracking Notice|$email_address" > /home/Mail/inbox/$$.${pid_index}message_info`;

  }

} else {
  
  `echo "Email Address: $email_address\nRemote Address $remote_addr\nProgram: contract_tracking.perl\nNo internet mailbox found for: $email_address{$email_address} | /usr/sbin/SMIMail -s "No Internet Mailbox found" admin\@emailaddy.com`;

  }

 }

}
 
What format are your dates in?
--Paul

27/10/2004-14 = ????

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
sorry, starting 'sed' in a 'perl'
is that not a little 'maso' ?
 
I have two date formats in here:

$current_date = $current_month/$current_day/$current_year

and

$current_date_alt = $current_year$current_month$current_day

The rest of the program calls uses the $current_date format. I'm not sure why the previous programmer had both, but it's not wrecking anything, so I'll leave it until I figure out more.

 
Code:
use Date::Calc;
$canonical = Date_to_Days($year,$month,$day);
($year,$month,$day) = Add_Delta_Days(1,1,1, $canonical - 15); # you'll need to test this -1 -14

Haven't tested this, but it's in the documentation


HTH
--Paul


It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top