Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is the code I used to strip an email body of the html formatting and all the characters so you are left with the actual email content. It looks like a mess, but it works:</p> <pre><code>foreach (Item item in findResults.Items) { MessageBody messageBody = new Microsoft.Exchange.WebServices.Data.MessageBody(); List&lt;Item&gt; items = new List&lt;Item&gt;(); if (findResults.Items.Count &gt; 0) // Prevent the exception { foreach (Item item2 in findResults) { items.Add(item2); } } service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties); messageBody = item.Body.ToString().Replace("&lt;html dir=", "").Replace("&lt;head&gt;", "").Replace("&lt;meta http-equiv=", "").Replace("content=", "") .Replace("&lt;style type=", "").Replace("&lt;/style&gt;", "").Replace("&lt;/head&gt;", "").Replace("&lt;body fpstyle=", "").Replace("ocsi=", "") .Replace("&lt;div style=", "").Replace("direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;", "").Replace("&lt;/div&gt;", "") .Replace("&lt;div&gt;", "").Replace("&lt;/body&gt;", "").Replace("&lt;/html&gt;", "").Replace("&lt;br&gt;", "").Replace("&gt;", "").Replace("\"Content-Type", "") .Replace("\"text/html; charset=utf-8", "").Replace("\"0", "").Replace("\"", "").Replace("text/css", "") .Replace("id=owaParaStyle", "").Replace("ltr", "").Replace("&lt;meta name=GENERATOR MSHTML 9.00.8112.16470", "").Replace("&lt;style P {", "") .Replace("MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px", "").Replace("&lt;p", "").Replace("&lt;/p&gt;", "").Replace("&lt;/p", "").Replace("&amp;nbsp;", "") .Replace("&lt;body fPStyle= ", "").Replace("%", "").Replace("&lt;", "").Replace("&gt;", "").Replace("}", "").Replace("\"","").Replace("body fPStyle=1",""); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload