Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 2nd, 2005, 10:48 AM   #1
eclipsed4utoo
Newbie
 
Join Date: Dec 2005
Posts: 7
Rep Power: 0 eclipsed4utoo is on a distinguished road
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?
eclipsed4utoo is offline   Reply With Quote
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
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:49 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC