我正在尝试以编程方式过滤 Outlook 2010 中“联系人”文件夹中的 Outlook 联系人。我遵循 DASL 过滤器规则,但是Find
当我将此过滤器分配给view.Filter = FilterString
. 任何想法我做错了什么?正确的结果将在现有联系人视图中显示过滤的联系人。
Outlook.Application myApp = ThisAddIn.myApp;
Outlook.NameSpace myNamespace = ThisAddIn.nSpace;
Outlook.MAPIFolder myContactsFolder = ThisAddIn.contactsFolder;
if (myContactsFolder == null)
{
Log.Verbose("Contacts folder not found");
return null;
}
Outlook.Items contactItems = ThisAddIn.contactItems;
//use filter to take only contact and not DistListItem
Outlook.Items outlookContacts = contactItems.Restrict("[MessageClass] = 'IPM.Contact'");
Outlook.ContactItem contact = null;
int iOutlookContacts = contactItems.Count;
if (iOutlookContacts > 0)
{
string FilterString = "[FullName]='" + param + "'";
// Find works with this filter
contact = (Outlook.ContactItem)outlookContacts.Find(FilterString);
if (contact != null)
{
// need to display in contacts search window
Outlook.View currentView = myApp.ActiveExplorer().CurrentView;
currentView.Filter = FilterString; // cannot parse exception occurs here
currentView.Save();
currentView.Apply();
}
}