I would like to search the bodies of all outlook items. I know how to do this for the four PIM items (Notes/Tasks/Appointments/Contacts). But the code is identical for all of them with the exception of casting the COM object to the specific item type (i.e., ContactItem, AppointmentItem, etc). Is there a parent class for these PIM items, so that I can do something like this in my loop:
using Outlook = Microsoft.Office.Interop.Outlook
List SearchFolderItems( Outlook.Folder folder )
{
List results = new List();
foreach( object folderItem in folder.Items )
{
//GenericPIMItem is what I am wishing for
Outlook.GenericPIMItem item = (Outlook.GenericPIMItem)folderItem;
if( item.Body.ToLower().Contains( "secret sauce" ) )
{
results.Add( item.Name );
}
}
}
Body is a common property of the four PIM items I want to get at. Is there such a parent item? Seems poor API design if not? I suppose I could abstract the folder item, to make it look like there is a parent item... I also tried to do this using reflection, but couldn't quite get there.
Any suggestsion?