
pichels
Novice
Mar 31, 2009, 1:28 PM
Post #4 of 29
(16457 views)
|
Re: [pichels] Find file w/ date suffix and email attachment?
[In reply to]
|
Can't Post
|
|
Hmmmm.... I added as an attachment? Here it is... #!/usr/bin/perl #use strict; use MIME::Lite; use Date::Calc qw( ); my ($Y,$M,$D) = ('','',''); # Original year,month,day my ($y,$m,$d) = ('','',''); # Resulting year,month,day # Year ($y,$m,$d) = year(); #print format_date($y, $m, $d); my ($tdate) = format_date($y, $m, $d); # ---------------------------------------- # subs # ---------------------------------------- # Year # Usage: ($y) = year([$y]); sub year { my ($y,$m,$d) = (scalar(@_) == 1) ? (shift, 1, 1) : Today(); $m = 1; $d = 1; return ($y, $m, $d); } # Formatted date (YYYYMMDD - possible zero padding) # Usage: $string = format_date([$y, $m, $d]); sub format_date { my ($y,$m,$d) = Today(); return sprintf("%04d%02d%02d", $y, $m, $d); } #print "\n"; $mydir = "."; opendir(DIR, "$mydir"); @drmfile = grep(/PLAN.$tdate.*$/,readdir(DIR)); closedir(DIR); foreach $file (@drmfile) { #print "$file\n"; #my %params; #$params{first_name} = 'TSM'; #$params{last_name} = 'Reports'; #my %options; #$options{INCLUDE_PATH} = '/path/to/templates'; my $msg = MIME::Lite::TT::HTML->new( From => 'tsm_reports@company.com', To => 'tsmadmin@company.com', Subject => 'TSM DR Plan', #Template => { # text => 'test.txt.tt', # html => 'test.html.tt', # }, #TmplOptions => \%options, #TmplParams => \%params, ); # Set our content type properly $msg->attr("content-type" => "multipart/mixed"); # Attach a PDF to the message $msg->attach( Type => 'application/txt', Path => 'C:\recoveryplans\', Filename => '$drmfile', Disposition => 'attachment' ); $msg->send('smtp', '10.97.24.104', Timeout => 60 ); } Thanks! -P
|