Multiple Attachments

M

mike

If I have multiple files to include in my sendmail how would I do that?

part of my pgm looks like:

my $msg = new MIME::Lite
To =>$To,
From =>$from,
Subject =>'The subject message',
Type =>'multipart/mixed';

attach $msg
Type =>'text/html',
Data =>$mymsg;

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Path =>$attch_file;

$msg->send;

So, the variable "$attch_file" would it be a listing of the files to be
sent? What would it look like?

If I had 2 files to attach would I have:

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Path =>$attch_fileA;

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Path =>$attch_fileB;

and of course if i didn't know how many files I was processing i then
would iterate across an array or hash?

Any help is appreciated.

Mike
 
J

J. Gleixner

mike said:
If I have multiple files to include in my sendmail how would I do that?

part of my pgm looks like:

What's a pgm?
attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Path =>$attch_file;

$msg->send;

So, the variable "$attch_file" would it be a listing of the files to be
sent? What would it look like?

The docs seem pretty clear:

"Path to a file containing the data... actually, it can be any
open()able expression. If it looks like a path, the last element will
automatically be treated as the filename."

$attch_file='/some/path/to/my/file.doc';
If I had 2 files to attach would I have:

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Path =>$attch_fileA;

attach $msg
Type =>'application/msword doc',
Disposition =>'attachment',
Path =>$attch_fileB;

What happened when you tried it? You'd save yourself a lot of time by
giving it a try & reading the documentation. If it doesn't work, as you
expect, post the code and the error.
and of course if i didn't know how many files I was processing i then
would iterate across an array or hash?

Yes.
 
U

usenet

mike said:
my $msg = new MIME::Lite

Can you use a different module? I prefer Mail::SendEasy:

my @files_to_send = qw/foo.doc bar.txt baz.xls/;

my $mail = new Mail::SendEasy;
$mail->send( to => $To,
from => $from,
subject => 'The subject message',
msg => 'Some files are attached. Enjoy!',
annex => \@files_to_send,
#or annex => ['foo.doc', 'bar.txt', 'baz.xls'],
#or annex => 'foo.doc', #single file
) || die Mail::SendEasy::error;

This, of course, imposes the burden of figuring out the MIME type upon
the target system. Since the target appears to be Windows, this
shouldn't be a problem as long as the file suffixes are recognized.
 
M

mike

That's really cool .....

I was just going to ask about the different file types that could be
sent so that answers that.

Let me see if Mail::SendEasy is installed.

Mike
 
B

bohhem

annex => \@files_to_send,
#or annex => ['foo.doc', 'bar.txt', 'baz.xls'],
#or annex => 'foo.doc', #single file
) || die Mail::SendEasy::error;
Hello,
I have a problem with anex part of Mail::SendEasy Modul, specific with
the file path under win32.
I have try to use the UNC paths ( \\machine\folder\file ) without
success. By using Local Path (c:\folder\file) everything goes without
problems.
But if I use something like this: //machine//update.log or
\\\\machine\\update.log the program ends with the Errormsg: Invalid
Anex: /Machine/update.log
I'm a Perl newbie, and therefor I suppose there is a trivial way to to
manage the UNC paths also.
Thanx Kenan A.
 
M

mike

You need to use a file specification that is on the machine where your
script is running from.

Just use:

/rootfolder/folder/file.doc

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top