Show simplier version of mail

+1 vote
asked Aug 6, 2010 by user-226 (google) (130 points)
edited Aug 6, 2010

We are building a portal and want to display some of the mail items and let people read the latest mail. The issue is that some mail is just too big and formatted to show in a webportal so we would like a method of stripping out the formatting and getting to a text based mail version if possible.

Ideally we still have some caraige returns and things like that but no huge hardcoded or poorly coded mails

Ideas?

Applies to: Rebex Secure Mail

1 Answer

+1 vote
answered Aug 6, 2010 by Martin Vobr (12,940 points)
edited Aug 6, 2010

Many email clients send both Html and Text version of the body. Try showing MailMessage.BodyText instead on MailMessage.BodyHtml on your web page.

If auto conversion from Html to Text is needed I would prefer using some of ready-made libraries over writing my own. You have to handle things like:

  • parsing HTML entities
  • unclosed tags
  • malformed html
  • malicious scripts in spams

Some people recommend using a HtmlAgility Pack.

Following articles on StackOverflow.com might also help:

...