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..