This might not be what you are looking for, but I will mention it anyway; there is a piece of software called Email Detail Archive
https://emailindetail.com/archive-emails that kind of lets you do this. I have used it recently to archive Outlook, and it does the same for Gmail.