我試圖以編程方式篩選在Outlook 2010中的聯繫人文件夾的Outlook聯繫人我跟着DASL過濾規則,但它似乎對Find
功能工作,並拋出異常時,我給你這個過濾器view.Filter = FilterString
。任何想法我做錯了什麼?正確的結果會在現有的聯繫人視圖中顯示已過濾的聯繫人。在Outlook 2010中編程過濾添加聯繫人,在
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();
}
}
您應該添加您的具體錯誤信息,即:'不能分析條件。錯誤在 「[全名] = '...'」。' – SliverNinja