What I would like to have some assistance with, is determining the type of MailItem loaded into the object using the following snippet of code. You will see I load the object from the active explorer selection and test if it is a mail item. What I would like to avoid picking up are objects like read receipts, meeting acknowledgments, and so forth and to test each type of object I would like to get its type - I attempt to test for that in the else statement below - but all I get in the debug window is "Not a Mail Item: I am a :System.__ComObject"
.
// set the mail item
object selectedItem = Globals.ThisAddIn.Application.ActiveExplorer().Selection[1];
// This example uses only MailItem.
if (selectedItem is Outlook.MailItem)
{
// Cast selectedItem to MailItem.
Outlook.MailItem mailItem = selectedItem as Outlook.MailItem;
// Do something with the MailItem
}
else
{
// what sort of item are we?
Debug.WriteLine("I am not a Mail Item: I am a :" +
selectedItem.GetType().ToString());
}