Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

MIME to attach

by nathanvit (Beadle)
on Jan 14, 2005 at 13:54 UTC ( [id://422235]=perlquestion: print w/replies, xml ) Need Help??

nathanvit has asked for the wisdom of the Perl Monks concerning the following question:

Hello, i'd like to download mail messages from a remote mailbox, catch attachments and put them in a directory...
I use Mail::POP3Client to download them and i use HeadAndBodyToFile method to write messages in a file.
So i've a file in mime format... So i want to convert it in attachment files but i can't understand how!!
i use:
$p = new MIME::Parser; $p->output_dir("mime"); $e=$p->parse_open("prova.MSG") or die "Non ce la faccio!!\n\n"; $e->dump_skeleton; $body=$e->bodyhandle; $num=$e->parts; print "Parti: $num\n";
It prints "Parti: 0"... Why there are no mime parts???

Replies are listed 'Best First'.
Re: MIME to attach
by steer (Initiate) on Jan 14, 2005 at 15:10 UTC
    At first glance that looks OK to me. I have attached an example multi-part mime message that seems to work fine with your code. Check the messages that you are feeding in and see if they are really multi-part.
      What is the character at the end of the line? Is it \n?
      I used to populate my file:
      for($i=1; $i<=$mail->Count(); $i++){ open(FILE,">prova.MSG"); foreach($mail->HeadAndBody($i)){ print FILE "$_ \n"; } close(FILE); $mail->Close(); }
      Is it correct? My message is similar to yours:
      Return-path: <vittorio.zuccala@ditta.it> Envelope-to: vittorio.zuccala@ditta.it Delivery-date: Fri, 14 Jan 2005 16:37:57 +0100 Received: from [192.168.50.195] (helo=[192.168.50.195]) by debianexim.finconsumo.it with esmtp (Exim 4.34) id 1CpTWO-0003GE-QV for vittorio.zuccala@ditta.it; Fri, 14 Jan 2005 16:37:57 +0100 ...... This is a multi-part message in MIME format. --------------030508080500040304000008 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit ... --------------030508080500040304000008 Content-Type: application/pdf; name="PlainLanguage.pdf" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="PlainLanguage.pdf"
      But it tells me there are 0 parts but that mail has 3 attachments!! Any suggestions please?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-26 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found