Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Saving attachments from email files

by dave0 (Friar)
on May 02, 2005 at 17:26 UTC ( #453334=note: print w/replies, xml ) Need Help??

in reply to Saving attachments from email files

You're part-way there with MIME::Parser, but you're not actually using the return value of ->parse() for some reason. Try something like this as a starting point:

my $entity = $parser->parse( IO::File->new( "$dir/raw-message.$i") ); foreach my $part ($entity->parts()) { # Look at $part (a MIME::Entity object) and determine what to do +with it }

MIME::Parser::parse() will return a top-level MIME::Entity object for the message. If it's a multipart message, you can get the separate MIME::Entity objects for each subpart by iterating over $entity->parts().

Then in that foreach loop, you can examine the content-type or filename of each part and determine what you want to do with it.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2021-04-21 08:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found