Home
TeamSite
Email Attachments
Randy
As I understand iw_sendmail doesn't support email w/attachments at this time. Am I correct about this? And if so.
Does any one have any info on things I should try or avoid if I try to implement this?
Find more posts tagged with
Comments
Migrateduser
You are correct; iwsend_mail.ipl does not support attachments. However, since it is a Perl script you could make a copy of it and add this capability. (This is one of the benefits of Perl.)
Regardless of
how
you send attachments, you should always consider (1) that you increase the size of the message, which has an impact on storage [this is especially important if you send the message to multiple recipients], (2) that the recipient may not have the same applications that you have to read the attachment, and (3) that if the message is opened at a later date it may contain obsolete information.
There are many times when an attachment is desirable, but there are tradeoffs to be made.
Brinko Kobrin
Interwoven Staff Engineer
mgal
An example Subroutine which allows you to send attachments :
use MIME:Lite;
#
@email
is a list of emails including
@domainname
.com
# $new_subject is the subject you want the message to have
# $new_msg is the content of the message
# \
@failed_files
is a list of files to parse and add to the email.
send_mail_file( \
@emails
, $new_subject, $new_msg, \
@failed_files)
;
sub send_mail_file{
my $To_array_ref = $_[0];
my $Subject = $_[1];
my $Body = $_[2];
my $send_File_ref = $_[3];
$msg = "";
my $To_List = '';
foreach my $to (
@$To_array_ref){
$To_List .= "$to, ";
}
$To_List =~ s/(.*)\S\s+$//ig;
$To_List = $1;
## Create the mail first.
$msg = MIME::Lite->new(
From =>"$Mail_From",
To =>"$To_List",
Subject =>"$Subject",
Type =>'multipart/mixed'
);
### Add the text message part:
### (Note that "attach" has same arguments as "new"):
$msg->attach(
Type =>'TEXT',
Data =>"$Body",
);
foreach my $FileNamePath (
@$send_File_ref){
$FileNamePath =~ /.*\\(.*\..*)/ig;
my $File_Name = $1;
$msg->attach(
Type => 'AUTO',
Path => $FileNamePath,
Filename => $File_Name,
Disposition => 'attachment',
Encoding => 'base64'
);
}
MIME::Lite->send('smtp', "$Mail_Smtpsvr", Timeout=>60);
$msg->send();
}