![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Dec 2005
Posts: 7
Rep Power: 0
![]() |
Problem with Perl script
Hey guys...as you can see, I'm new here. I've been programming with Perl for about 2 months now so I am still kinda new to it.
I am currently writing a script that will email excel attachments to a number of people. My script will make sure that the file is there, then attach it to an email, and send it out. However, here is the problem. When somebody tries to open the attachment from the email, it gives the "[filename] cannot be accessed. The file may be read-only, or you may be trying to access a read-only location." error message. When i send it manual, the file open fines. Anybody have any ideas as to why it gives this error message? |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Dec 2005
Posts: 7
Rep Power: 0
![]() |
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";
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|