Validating html is a very complicated issue. You can check whether the message includes the closing </html> tag.
Thank you Erel. I’m finding that trying to load ALL emails received into a WebView to be a daunting tast. I tried your <html> suggestion and find it to be hit and miss. There are some content types/encoding that the Mailparser cannot process correctly. I can, with a few unwanted characters such as =0A stripped out, display acceptably about 85% of messages received. Others come through the Mailparser malformed, or occasionally stripped to a 0 bytes file.
When I started I thought this would be a fairly straightforward task, but it turns out not to be so. I think the only way to resolve this issue, would be to update the Mailparser to process all current formats. I don’t know whether this would be easily accomplished, or be a major undertaking. I don’t have the knowledge to do this, otherwise I would give it a try. Erel, perhaps if I have caught you on a good day, you will put your considerable skills to the task. I’m sure a great many of us would appreciate an upgraded Mailparser.
I have attached three examples of malformed HTML as processed by the Mailparser. Two are missing <html>, while the third includes <html> with a trailing <.
Best regards