I have following email message.
after running the following code
string pattern = "<img src=\"cid.*?</span></p>|Inline image 1.*?</FONT>";
Outlook.Selection mySelection = Globals.ThisAddIn.Application.ActiveExplorer().Selection;
Outlook.MailItem mailitem = null;
foreach (Object obj in mySelection)
{
if (obj is Outlook.MailItem)
{
mailitem = (Outlook.MailItem)obj;
string body = mailitem.HTMLBody;
Regex reg = new Regex(pattern, RegexOptions.Compiled | RegexOptions.Multiline|RegexOptions.Singleline);
MatchCollection matchs = reg.Matches(body);
foreach(Match match in matchs)
{
string a = match.Groups[0].Value;
mailitem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
mailitem.Body = body.Replace(a, string.Empty);
mailitem.Save();
}
//mailitem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain;
}
}
I got following email message in outlook .
The body text works in browser. It means when i saved the body text in simple html file it works properly and display original message.