Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Mail with attachments, but w/o writing out a file first

by petdance (Parson)
on Sep 20, 2001 at 00:01 UTC ( #113463=note: print w/replies, xml ) Need Help??


in reply to Mail with attachments, but w/o writing out a file first

Here's a chunk of code that is in production at my office:
my $subject = "FLR invoices"; my $msg = MIME::Entity->build( From => SOURCE, To => TARGET, Subject => $subject, Type => "multipart/mixed", ); my $textpart = <<END; Attached is the XML file $xmlfile. Andy END # Add the text greeting $msg->attach( Type => 'text/plain', Encoding => '7bit', Data => $textpart, ); # Add the XML file $msg->attach( Type => 'text/xml', Encoding => 'base64', Description => "XML file $xmlfile", Path => $xmlfile, ); $msg->send( 'sendmail' );
Note that the body is specified thru a variable, and the attachment is a file. I'm pretty sure you don't have to specify a filename when you create the attachment.

xoxo,
Andy
--
<megaphone> Throw down the gun and tiara and come out of the float! </megaphone>

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://113463]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2021-05-14 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?