$file_attach{'testdoc.doc'} = '/home/path/to/document/testdoc.doc';
etc...
# I've tested the %file_attach hash and it does contain the correct path and file name.
$email_msg = MIME::Lite->new (
Return-Path=>'me@here.com',
From =>'me@here.com',
To =>$email_to,
Subject =>"Completed Documents ($doc_count attached)",
Type =>'multipart/alternative',
);
$email_msg->attach (Type =>'text/plain',
Encoding=>'7bit',
Data =>$plain
);
$email_msg->attach (Type =>'text/html',
Data =>$html_body,
Encoding =>'7bit',
);
foreach $file (keys %file_attach) {
$email_msg->attach (Type =>'application/msword',
Path =>$file_attach{$file},
Filename=>$file,
Disposition=>'attachment',
Encoding =>'base64'
};
####
(header)
Content-Type: multipart/alternative; boundary="_----------=_AAA"
(body)
This is a multi-part message in MIME format.
--_----------=_AAA
Content-Type: text/plain
Plain Text Message Here
--_----------=_AAA
Content-Type: text/html
HTML Message Here
--_----------=_AAA
Content-Disposition: attachment; filename="test2.doc"
Content-Transfer-Encoding: base64
Content-Type: application/msword; name="test2.doc"
--_----------=_AAA--
####
(header)
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_AAAAA"
(body)
This is a multi-part message in MIME format.
------=_NextPart_000_AAAAA
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_BBBBB"
------=_NextPart_001_BBBBB
Content-Type: text/plain;
Plain Text Message Here
------=_NextPart_001_BBBBB
Content-Type: text/html;
HTML Message Here
------=_NextPart_001_BBBBB--
------=_NextPart_000_AAAAA
Content-Type: application/msword; name="test.doc"
Content-Transfer-Encoding: base64