Save/Re-date Apple Mail Messages/Attachments

I’m looking to save to the iMac every email as an .eml file, and every attachment located in an archived Apple Mail folder, and then modify their timestamps to match the original date and time they were received instead of when they were downloaded.

I believe there’s a way to do this without having to worry about the timestamp for all new incoming emails by setting up a rule that would perform the downloads as soon as they arrived, but that doesn’t help me with all the older emails that have been long archived.

You can extract attachment from .eml by using MailCore.

I wrote attachment extractor in 6 years ago.
So, you can wtite such an AppleScript by using it.