I'm currently trying to get just the contacts from an Items collection retrieved from Outlook. The problem is that my cast to ContactItem sometimes breaks because there are non-contact items in the list (like distribution lists). Because these are COM objects, I need to check if the property MessageClass
equals IPM.Contact
. I'm not familiar with COM objects, so I don't know how to do this. I've tried using the following:
if(comObject.GetType().GetProperty(MessageClass).GetValue(comObject).Equals("IPM.Contact"))
{
contactitems.add((ContactItem)comObject)
}
However, this fails because it cannot find the property on the comobject.
I checked MSDN, and they suggest at http://msdn.microsoft.com/en-us/library/ms268994.aspx to use object is ContactItem
to check if it's a ContactItem. I've tried this, and it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.