Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: MIME::Lite $message construction with variables

by Enlil (Parson)
on Jun 10, 2004 at 21:59 UTC ( [id://363227]=note: print w/replies, xml ) Need Help??


in reply to MIME::Lite $message construction with variables

How bout something like this (untested but should work):
sub Email_Results{ $msg = MIME::Lite->new( From => 'net-admin@someplace.org', To => 'decoraw@someplace.org', Subject => 'Trying to send attachment', Type => 'multipart/mixed'); $msg->attach( Type => 'text/html', Data => << "EOHTML" <html> <head> <title>Human Resources : Application for Employment</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 +-1"> </head> <body bgcolor="#FFFFFF" marginwidth="0" marginheight="0" class="margin +"> <table width="600" border="0"> <tr valign="top"> <td width="300"><font face="Arial, Helvetica, sans-serif" size=" +-1"> <b>Name:</b>&nbsp;<i>$name</i></font> </td> </tr> </table> </body> </html> EOHTML ); $msg->attach( Type => 'application/octet-stream', Path => "$Directory/$File_Name", Filename => $File_Name ); $msg->send(); }
Granted you could probably use some templating system to create the message for example Template Toolkit as shown in the introduction doc, pass the results to a variable then attach that to Data. Also if you use ' instead of " for quoting text you will not be able to interpolate variables (though with eval you could get back what you wanted as well)

-enlil

Replies are listed 'Best First'.
Re^2: MIME::Lite $message construction with variables
by drewbie (Chaplain) on Jun 11, 2004 at 03:20 UTC
    $msg = MIME::Lite->new( From => 'net-admin@someplace.org', To => 'decoraw@someplace.org', Subject => 'Trying to send attachment', Type => 'multipart/mixed');
    BTW, the "Type" param is not needed in the call to new(). When calling $msg->attach later, the object will automatically set the Type as needed. See the docs for more details.

    And I agree that MIME::Lite is definitely one of the coolest things since sliced bread. Major kudos to the author. I'm using it at work to mail out dynamically generated PDF's, and I think it took me all of 5 minutes after reading the docs to have working code. That's a well designed module. :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-16 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found