c# - Parsing text from HTML formatted email -
i inbound emails html formatting below (probably copy/pasted office , sent outlook) causes formatting issues when html enabled ui displaying email content.so resolve copy html content online html editor or save html file , run in browser can copy text rid of garbage html , styling tags. dont have option of using frames in markup suppress html , css , prevent affecting page styling.
is there other way can resolve issue pragmatically , parse text out every time detect 'urn:schemas-microsoft-com:vml' in body of inbound emails?
i went far writing code removes tags (e.g. between <head>
, </head>
) see if can offer more efficient way of handling or alternate frames suppress bad html in email body content on ui
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/tr/rec-html40"><head> <meta http-equiv="content-type" content="text/html; charset=us-ascii"> <meta name="generator" content="microsoft word 15 (filtered medium)"> <style><!-- /* font definitions */ @font-face {font-family:wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;} @font-face {font-family:pmingliu; panose-1:2 2 5 0 0 0 0 0 0 0;} @font-face {font-family:"cambria math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:"\@pmingliu"; panose-1:2 2 5 0 0 0 0 0 0 0;} @font-face {font-family:"berlin sans fb"; panose-1:2 14 6 2 2 5 2 2 3 6;} /* style definitions */ p.msonormal, li.msonormal, div.msonormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"times new roman",serif;} a:link, span.msohyperlink {mso-style-priority:99; color:#0563c1; text-decoration:underline;} a:visited, span.msohyperlinkfollowed {mso-style-priority:99; color:#954f72; text-decoration:underline;} p {mso-style-priority:99; mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; font-size:12.0pt; font-family:"times new roman",serif;} span.emailstyle18 {mso-style-type:personal-reply; font-family:"calibri",sans-serif; color:#1f497d;} .msochpdefault {mso-style-type:export-only; font-family:"calibri",sans-serif;} @page wordsection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;} div.wordsection1 {page:wordsection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1" /> </o:shapelayout></xml><![endif]--> </head> <body lang="en-us" link="#0563c1" vlink="#954f72"> <div class="wordsection1"> <p class="msonormal"><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#1f497d"><o:p></o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#1f497d">see below. </span><span style="font-size:11.0pt;font-family:wingdings;color:#1f497d">j</span><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#1f497d"><o:p></o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#1f497d"><o:p> </o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#c45911">please note following: <o:p></o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#c45911">m<o:p></o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#c45911"><o:p> </o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"calibri",sans-serif;color:#c45911"> <o:p></o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"berlin sans fb",sans-serif;color:#1f497d"><o:p> </o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"berlin sans fb",sans-serif;color:#1f497d">thank you!<o:p></o:p></span></p> <p class="msonormal"><span style="font-size:11.0pt;font-family:"berlin sans fb",sans-serif;color:#1f497d"><o:p></o:p></span></p> </div> </div> </body> </html>
i ended using chilkat's htmltotext method , it's brilliant.
thanks
Comments
Post a Comment