Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Saving certain email attachements using MIME::Tools

by blahblahblah (Priest)
on Aug 30, 2002 at 00:04 UTC ( #193951=note: print w/replies, xml ) Need Help??


in reply to Saving certain email attachements using MIME::Tools

I think this would work:
$body = $entity->bodyhandle; $filename = $body->path;

Replies are listed 'Best First'.
Re: Re: Saving certain email attachements using MIME::Tools
by neilwatson (Priest) on Aug 30, 2002 at 13:18 UTC
    $body returns: MIME::Body::InCore=HASH(0x83a39ac) while $filename comes out blank.

    Update

    foreach $x (@attypes){ if ($subentity->mime_type =~ m/$x/i){ $attachment = $subentity->bodyhandle->print(); push @attachment, $attachment; print "x = $x subentity =".$subentity->mime_type."\n"; push @attname, $subentity->head->mime_attr('content-disposition. +filename'); } }

    The attachment prints out but is not stored in $attachment. @attname now holds the attachment name correctly. All that remains is figuring out how to store the attachement into a variable for later use.

    Neil Watson
    watson-wilson.ca

      You're setting $attachment to the return value of the print() method. The perldoc for MIME:Body doesn't say anything about print() returning anything. There are other methods that look like they'll do what you want, like as_string() and as_lines().

      MIME::Tools has some of the better documentation I've seen for modules, with lots of examples. You should run "perldoc MIME::Body" or look at these pages on perldoc.com:
      http://www.perldoc.com/cpan/MIME-tools.html
      http://www.perldoc.com/cpan/MIME/Body.html

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://193951]
help
Chatterbox?
[GotToBTru]: late to the conversation .. but thanks, Corion, for the reminder about Perl::Tidy
[Corion]: GotToBTru: Heh ;) I'm not really endorsing it, as I found that any gains made through it are easily squandered by the hours spent on configuring it. At least in my case :)
[GotToBTru]: Like most Swiss Army Knives, you can cut yourself trying to find the blade you actually want
[GotToBTru]: i am satisfied with the default settings turning the seemingly random formatting into something reliable
[Corion]: GotToBTru: Yeah, I started a quick(ly implemented but slowly running) implementation of a program that would guess the "best" configuration (that is, least amount of changes) from my code, but then found that it stops parsing the source as soon as it ..
[GotToBTru]: sadly, it can't do anything about this
[Corion]: ... encounters sub foo($bar,$baz) {, which is something I like nowadays

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2017-02-27 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (387 votes). Check out past polls.