Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

RE: MIME Attachment Extractor

by Punto (Scribe)
on Jun 01, 2000 at 19:26 UTC ( #15841=note: print w/replies, xml ) Need Help??

in reply to MIME Attachment Extractor

I have 1 question: if the e-mail has only 1 part (the body of the msg), the .doc file is created, @parts is empty, and the file never gets deleted on the "for $part (@parts)" loop. Is there a way to get the name of the file when there are no attachments?

Replies are listed 'Best First'.
RE: RE: MIME Attachment Extractor
by Punto (Scribe) on Jun 01, 2000 at 22:09 UTC
    I got it! :)
    Instead of using:
    $content .= $body->as_string if defined $body;
    I do:
    if (defined $body) { $content .= $body->as_string; $filename = $body->path; unlink($filename); };
    and it works fine.. Thanks..
RE: RE: MIME Attachment Extractor
by httptech (Chaplain) on Jun 01, 2000 at 19:41 UTC
    Yes, the bodies are always saved with the prefix "msg-" (unless you override it). So you can just unlink anything that starts with that prefix to clean out the message bodies.
      What if while I'm deleting, another program is creating a file, and it's not done with it yet? The module Mime::Parse may lock the file, but then the sub open the file..

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2023-09-30 12:07 GMT
Find Nodes?
    Voting Booth?

    No recent polls found