Refactors generating the mime structure to use multipart/related only if required