Archived Forum Post

Index of archived forum posts


Mime to XML back to MIME

Jul 30 '12 at 17:07

I'd like to use the mime.savexml feature to convert a mime message to xml so we can parse and process it. At some point in the furture however we want to take the xml version of the message and recreate the mime data.

I build a small sample program that did the following

success = mime.LoadMimeFile("c:tempinput.eml")
success = mime.SaveXml("c:temptemp.xml")
success = mime.LoadXmlFile("c:temptemp.xml")
success = mime.SaveMime("c:tempoutput.eml")
I was expecting that the input.eml and output.eml to be the same. But there are differences. Should I expect them to be the same ? I can send you the files for review, just let me know.

Accepted Answer

You should expect whitespace differences in the header fields, and possible re-formatting w/ continuation lines to adhere to standards that would make the MIME the least troublesome possible.


It is a bit worse than that. Can you please send me an email address I can forward examples to ?


Thanks. Yes, send it to


Thanks for the information. The differences are to be expected. The differences are:

1) Whitespace and header folding / continuation line differences.

2) Header field uppercase/lowercase differences. MIME header field names are case-insensitive, so this should make no difference. In addition, the header field names become XML tags, and therefore it's required that they are canonicalized to all lowercase in the XML representation. When translating back, the header fields are all lowercase. But again, this shouldn't make any difference.

3) The Base64 / quoted-printable line-lengths used in the MIME bodies might be changed. Chilkat will make sure the line-lengths are according to published standards. If the original MIME used non-standard line-lengths, there may be a difference. Again, this is inconsequential because the content is not actually changed -- only the encoded representation.