CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Find file w/ date suffix and email attachment?

 

First page Previous page 1 2 Next page Last page  View All


pichels
Novice

Apr 1, 2009, 8:16 AM

Post #26 of 29 (1247 views)
Re: [FishMonger] Find file w/ date suffix and email attachment? [In reply to] Can't Post

Ok - thanks FM.

Here is the code w/ tags:



Code
 
!/usr/bin/perl

use strict;
use warnings;

use MIME::Lite;
use POSIX qw(strftime);


my $tdate = strftime("%Y%m%d", localtime);
my $file;

#print $tdate,"\n";


my $mydir = ".";
opendir(DIR, "$mydir");
my @drmfile = grep(/PLAN.$tdate.*$/,readdir(DIR));
#my @drmfile = grep(/\.pl$/,readdir(DIR));
closedir(DIR);


#foreach $file (@drmfile) {

#print $file,"\n";

#}

#my $msg = MIME::Lite->new(
# From => 'tsm@abc.com',
# To => 'p@abc.com',
# Cc => 'some@other.com, some@more.com',
# Subject => 'TSM DR Plan',
# Type => 'multipart/mixed',
#);

#$msg->attach(
#Type => 'TEXT',
#Path => 'C:\\Scripts\\$file\',
#Filename => '$file',
#Disposition => 'attachment',
#Data => "$file",
#);

#$msg->send('smtp', '10.97.24.104', Timeout => 60 );


#}



FishMonger
Veteran / Moderator

Apr 1, 2009, 8:21 AM

Post #27 of 29 (1244 views)
Re: [pichels] Find file w/ date suffix and email attachment? [In reply to] Can't Post

My previous post shows how you need to attach the file. Adjust your script accordingly and see what happens.


pichels
Novice

Apr 1, 2009, 8:47 AM

Post #28 of 29 (1241 views)
Re: [FishMonger] Find file w/ date suffix and email attachment? [In reply to] Can't Post

Excellent! Works now.

Ok - Don't suppose I could trouble you w/ another question?

If I want to add more "text" files in two different dir's but they will have the "same" or consistent filenames - not changed by date - I could change/add more code to the MIME part ?


Code
 
msg->attach(
Type => 'text/plain',
Path => $file,
Filename => $file,
Disposition => 'attachment',
);

msg->attach(
Type => 'text/plain',
Path => 'C:\recoveryplans\',
Filename => 'devcng.out',
Disposition => 'attachment',
);


Right?
Thanks again!

-P



pichels
Novice

Apr 1, 2009, 9:23 AM

Post #29 of 29 (1239 views)
Re: [pichels] Find file w/ date suffix and email attachment? [In reply to] Can't Post

Ok - figured out.
Actually this seems to work fine...


Code
 
$msg->attach(
Type => 'text/plain',
Path => $file,
Disposition => 'attachment',
);

$msg->attach(
Type => 'text/plain',
Path => 'C:\\Mitel\\CommAddUsers.vbs',
Disposition => 'attachment',
);

$msg->attach(
Type => 'text/plain',
Path => 'C:\\Mitel\\HTTPCheck.txt',
Disposition => 'attachment',
);



Thanks again for your help!

-P

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives