Items.Find()返回的对象中是否有任何内容指示所述对象在调用Find()的集合中的位置?
Outlook.Application App = new Outlook.Application();
Outlook.MAPIFolder contactFolder = App.Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Items contactItems = contactFolder.Items;
Outlook.ContactItem matchItem = contactItems.Find(
"@SQL=urn:schemas:contacts:cn LIKE '" + searchString + "%'");
此时我需要matchItem
集合中的contactItems
索引。这可能吗?
答案 0 :(得分:0)
matchItem
指向的引用应该等于Items集合中的引用。因此,您应该能够遍历Items集合并通过引用相等性查找索引。您需要强类型列表中的项目:
//Change how you're accessing the items of this folder
//the new list should have the same references as the Items property
var contactItems = contactFolder.Items.OfType<Outlook.ContactItem>().ToList();
...
//then use the List's built-in IndexOf() function:
var index = contactFolder.IndexOf(matchItem);