in reply to How to get started with scraping my IMAP emails

I've had good success with Mail::IMAPClient, and then using MIME::Parser to extract parts.

Using MIME::Parser directly isn't all great because I found that I often need to recurse through the matryoshka-doll nested MIME parts myself in the code and finding the relevant part (text/html, or text/plain, or any of these, found recursively) is nasty. But I have the feeling that this is just how MIME parts are...

  • Comment on Re: How to get started with scraping my IMAP emails

Replies are listed 'Best First'.
Re^2: How to get started with scraping my IMAP emails
by bliako (Abbot) on Mar 01, 2022 at 13:39 UTC

    Do you mean that there is no MIME::Parser-built-in and easy way to unwrap an email with attachments fetched from server into a dir, each attachment on its own file, with a filename as specified by the message (if any, or just recomment one)? I have managed to tell MIME::Parser to save under a dir but it does not unwrap the message, message text and attachments are all in one big file. I also found this post of yours Re^3: read email-message. But I hesitate to start handling all these cases. I still looking for a built-in solution.

      Yes, that's unfortunately what I mean - at least I am unaware of a good/convenient way of handling that. I've written the linked subroutine in at least two or three incarnations, but I'm not sure that this would generalize in any meaningful way. Maybe having a way to query "the email" would make the interface better, like maybe CSS-style selectors or an SQL interface to select all attachments or everything that is part of an included mail etc. - but I haven't progressed to any approach that is not ad-hoc.