Fixed!
if (_explorer.Selection[1] is Outlook.MailItem)
becomes
bool isMailItem = false;
Object objectToInspect = _explorer.Selection[1];
Type type = objectToInspect.GetType();
try
{
if ((Outlook.OlObjectClass)type.InvokeMember("Class", System.Reflection.BindingFlags.GetProperty, null, objectToInspect, null) == Outlook.OlObjectClass.olMail)
{
isMailItem = true;
}
}
catch (Exception ex)
{
//eat
}
if (isMailItem)
Pretty obvious, really
Thanks a lot, Ken
kenslovak wrote on Wed, 31 March 2010 09:05
So try getting the item as an Object and using Reflection to get the Class
property or MessageClass property and examine the item type that way. See if
that causes the same problem as your cast.