As I understand it, you are attempting to write code to parse out error messages from your current test log and email them to interested parties in your organization. Is this correct?
Our of curiosity, is there a reason why an export of the log to an HTML page, centrally stored on a file server, and then coupled with an e-mail of the link to that file wouldn't work as well? The code would be much simpler and the end result would be the same. You could even build in the logic that you would send two different email messages. If there are errors, you would send one message with the link, if not, send a different one without the link.