Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Add-in problem: Process All Marked Header doesn't display email bodies (http://www.outlookbanter.com/add-ins-outlook/101518-add-problem-process-all-marked.html)

TTT April 1st 10 06:18 AM

Add-in problem: Process All Marked Header doesn't display email bodies
 
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.


Ken Slovak - [MVP - Outlook] April 1st 10 06:30 PM

Add-in problem: Process All Marked Header doesn't display email bodies
 
Good.

I've found that sometimes casting will have odd effects but testing for
Class or MessageClass as you did before casting prevents the problems, as
you found.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"TTT" alistair[at]timetracer[dot]com[dot]au wrote in message
...
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




All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com