J'ai un message électronique suivant.Outlook ne rend pas le contenu html
après avoir exécuté le code suivant
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;
}
}
Je suis message d'e-mail dans Outlook.
Le texte du corps fonctionne dans le navigateur. Cela signifie que lorsque j'ai sauvé le texte du corps dans un fichier html simple, cela fonctionne correctement et affiche le message original.