Re: attachment names
Mark Overmeer <[email protected]> Thu, 21 Jul 2005 08:41:52 +0200
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <[email protected]> |
* Simon, Michael S ([email protected]) [050721 02:15]: > my $message = Mail::Message->build > ( From => $from > , To => $to > , Cc => $cc > , Bcc => $bcc > , Subject => $subject > #, attach => $bodyParts[0] > # , file => $zipFile > ); > > Now how to I append parts to this email message? I could have multiple > attachments and possibly multiple parts as text/html. For sure I have > the text of the message. I may or may not have an attachment(s). > Any help is appreciated. You can attach multiple parts like this: Mail::Message->build(attach => \@bodyparts); or Mail::Message->build(attach => $parts[0], attach => $parts[1]); When you specify a file-name, the mime-type and such are automatically detected (as long as you have the filename-extensions right). If you want complex things, you need to do it in steps, for instance: my $p1 = Mail::Message::Body->new(data => \@lines); ... my $b = Mail::Message::Body::Multipart->new(parts => [$p1, ...]); my $m = Mail::Message->build(attach => $b); # multipart attached to msg or my $m = Mail::Message->buildFromBody($b); # multipart == msg > I'm looking to do something of the following nature. > foreach $body (@bodyParts) > { > $message-attachFile(); or > $message-attachText(); my $r = $body->attach(file => 'a.pgp'); Called on a multipart body, one part within the multipart will be added (and $r == $body), otherwise $r will be a multipart. -- MarkOv