MailMessage get HtmlBody as PlainText

+1 vote
asked Jun 22 by Ralf (130 points)

Is there something hidden in the MailMessage class that helps me getting a Html Body (only Html in the mail no Plaintext) as PlainText?

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Jun 22 by Lukas Pokorny (123,810 points)

Unfortunately, MailMessage does not include any a HTML-to-PlainText converter. You might consider using a third-party library for this task, such as HTML Agility Pack.

commented Jun 22 by Ralf (130 points)
thanks Lukas,

i actually have code that uses the HtmlAgilityPack just need to bring it into the .Net Core world. Current nuget package seem to be standard 2.0 so might be easy.

Was hoping for something even easier. Just need to parse those dammed Journal Reports from Exchange. The structure is as plain as it can be but still they made html out of it :(
commented Jun 22 by Lukas Pokorny (123,810 points)
Yes, we actually did consider adding a HTML-to-plain converter some time ago, but converting HTML to plain text is a surprisingly complicated task that might lead to all kinds of strange results in rare cases, so we abandoned the idea. We might reconsider it in future based on demand in this. It would be useful.
...