I'm working on an Outlook Add in, and I want to look for some specific tags in the html of the mail that the user is reading. For that matter, I'm using the ActiveExplorer's Selection change event.
currentExplorer.SelectionChange += new Outlook
.ExplorerEvents_10_SelectionChangeEventHandler
(CurrentExplorer_Event);
private void CurrentExplorer_Event()
{
if (this.Application.ActiveExplorer().Selection.Count == 1)
{
Object selObject = this.Application.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem)
{
Outlook.MailItem mailItem = (selObject as Outlook.MailItem);
lookForTags(mailItem.HTMLBody);
}
}
}
The problem is that for it to work the user has to click on the mail item twice because the first time, mail is still loading and and mailItem.HTMLBody returns this:
Then the second time, mail is done loading so mailItem.HTMLBody returns the real body and everything works fine. Is there any other event that is fired when the mail is done loading so that I can start executing my code? Or is there a better solution to avoid having an empty HTMLBody?