Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Saving attachments from email files

by dave0 (Friar)
on May 02, 2005 at 17:26 UTC ( [id://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?
Username:
Password:

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

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

    No recent polls found