refactor MailPart conversion into a separate function, and save every part to file (in case of error)