This fails your "does not create random files on disk" requirement, but you can use munpack to expand a multi-part MIME email into (ahem) multiple files on disk:

   munpack -tC randomFilesOnDisk/ ~/multipart.eml

       -t   Give me the text part of the email as well
       -C   Change into this directory first (which is why the
       fully-qualified path to the email file is required

When the email contains html with embedded images, munpack does not alter the image links to point to the random files on disk. You'd need to script that part.

Volker Kuhlmann wrote:
Is there a command line program which can extract the first attachment,
or even the first attachment of a given type? Reading stdin and writing
stdout would be an extra bonus, though it would be possible to script
around that. Important is that the program does not create random files
on disk (files with names supplied by the input email are considered
random).

Thanks,

Volker



=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================

Reply via email to