Brian McKee wrote:
> Hi All
> New list member - please shove me around as required :-)
>
> I've written a script to forward logs on an XP box.
> I'm a pretty newbie perl guy, and this is my first Win32 attempt
> so it's likely something obvious.
>
> Using MIME::Lite, it sends plain text fine, but gives me
> 'permission denied' when I try and attach a binary file.
>
> Does it matter that the system has no file association for the file type?
I think you could be getting a directory rather than a file when you
do the attach.
> The section I think is appropos is:
> ---------------------------------------------
> # if it's still here - attach it
> print "trying to attach binary file $currentPath - $_ \n " ;
> $msg->attach(
> Type => 'AUTO',
> Path => $currentPath ,
> Filename => $_ ,
> Disposition => 'attachment'
> );
> }
> my $folderEndLine = qq|
> End of $currentPath
> $headerLine
> | ;
> $msg->attach(
> Type => 'TEXT',
> Data => $folderEndLine ,
> ) ;
> }
> warn "Error sending e-mail: $!" unless $msg->send;
> -----------------------------------
1) I would replace $_ with $filename or some such in this section
foreach my $filename (@listOfFiles) {
just to be safe - too easy for $_ to get modified in a long code
section.
2) I would be more explicit in the attach:
$msg->attach(
Type => 'BINARY', # AUTO can cause problems if
bad guess
Encoding => 'base64', # I'd explicitly state the
encoding
# Path => $filename, # Path not really needed since
you chdir'd
Filename => $filename, # assumes $_ changed to
$filename
Disposition => 'attachment', # I'd use 'inline' for the text
files
);
_______________________________________________
Perl-Win32-Admin mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs