in reply to MIME::LITE - Body contents and attachments

$msg->attach(Type => "text/plain", Encoding => 'base64', Data => $OutFile);

The above simply adds the contents of the variable $OutFile to the message.

Looks like you want to print the contents of the file, not the filename itself.

I'm not restating your question in order to be obtuse, I'm hoping I'm nudging you enough to figure it out yourself.



--chargrill
$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}

Replies are listed 'Best First'.
Re^2: MIME::LITE - Body contents and attachments
by Anonymous Monk on Apr 19, 2006 at 15:05 UTC

    Based upon your coment, i'm pretty sure that you were driving at print() and/or print_body(). Unfortunatly, I was not able to get those to work(lack of knowledge). I tried a combination of using Path, FH, readnow, with no success. However, I was able to use data by cat'ing the file to a variable.

    If you would be so kind to possible disclose on how you would have gotten it to work with print() or print_body(), or what ever other means you were driving at, I would appreciate it.

    Thanks
    Gary

    #################################################### #### Emailing the Reports now #################################################### # Send An Email with Attachment $data = `${uxutil}cat ${OutFile}`; #print "Below is the contents of \$data\n$data\n"; MIME::Lite->send('smtp',"$Email_Server",Timeout=>60); $msg = MIME::Lite->new( From => 'Netbackup@company.net', To => "$Email_List", Subject => "${hostname} Robotic Tape Information", Type => 'multipart/mixed'); $msg->attach(Type => 'application/vnd.ms-word', Filename => `basename \"${OutFile}\"`, Path => "$OutFile", ReadNow => 1, Disposition => 'attachment'); $msg->attach(Type => "text/plain", Encoding => 'base64', Data => $data); $msg->send(); #################################################### #### End Emailing the Reports ####################################################

      No, I wasn't driving at print() or print_body(), I was driving at getting the contents of the file into $some_variable that you could dump into the email with Data => $some_variable, which you did, one way or another :)

      Personally, I wouldn't use qx{} to cat the contents of the file, I'd probably read it using your favorite flavor of open and <>, but as always, TIMTOWTDI.

      I'm glad you arrived at your own solution, though :)



      --chargrill
      $,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}