ytjPerl has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am able to send single attachment but not multiple attachments. Can Any one help? The following code only attached one file from the directory
my $msg = MIME::Lite->new ( From => $msgFrom, To => $msgTo, Subject => $msgSubject, Type =>'multipart/alternative', ) or die "Error creating multipart container: $!\n"; # Create the HTML part my $html_part = MIME::Lite::->new( 'Type' => 'multipart/related', ); $html_part->attach( 'Type' => 'text/html', 'Data' => qq{ <body> <p>hello</p> </body> }, ); my $att_part; my @files = glob("F:/folder/*"); $att_part = MIME::Lite::->new( 'Type' => 'application/octet-stream', 'Encoding' => 'base64', 'Path' => shift @files, ); $msg->attach($html_part); $msg->attach($att_part); my $email = $msg->as_string(); my $smtp = Net::SMTP_auth->new($smtphost, Port=>$smtpport) or die "Can +'t connect"; $smtp->mail($msgFrom) or die "Error:".$smtp->message(); $smtp->recipient($msgTo) or die "Error:".$smtp->message(); $smtp->data() or die "Error:".$smtp->message(); $smtp->datasend($email) or die "Error:".$smtp->message(); $smtp->dataend() or die "Error:".$smtp->message(); $smtp->quit or die "Error:".$smtp->message();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trouble with sending more than one attachment
by Corion (Patriarch) on Oct 18, 2020 at 15:29 UTC | |
by ytjPerl (Scribe) on Oct 19, 2020 at 18:57 UTC | |
by Corion (Patriarch) on Oct 19, 2020 at 20:07 UTC | |
|
Re: Trouble with sending more than one attachment
by AnomalousMonk (Archbishop) on Oct 18, 2020 at 18:15 UTC | |
by ytjPerl (Scribe) on Oct 19, 2020 at 18:56 UTC | |
by AnomalousMonk (Archbishop) on Oct 19, 2020 at 20:27 UTC | |
by pwagyi (Monk) on Oct 26, 2020 at 06:38 UTC |