使用 MAPI 的 Outlook 自定义字段过滤

Outlook Custom field filtering using MAPI

我尝试过滤自​​定义属性获取 Outlook 中的联系人。我保存了用户 属性 呼叫 "SyncValue"。它有字符串值。我尝试检查这些值并让 contactitem 具有 属性 值。

Outlook.ContactItem contactItem = null;
string syncVal = (char)34 + "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/SyncValue" + (char)34;
Outlook.MAPIFolder contacts = Globals.objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Items contactItems = contacts.Items;
string filter = "WHERE (" + syncVal + " = 'True')";
contactItem = contactItems.Find(filter) as Outlook.ContactItem;

您的过滤器字符串必须以 @SQL= 为前缀。你不应该使用 "WHERE":

string filter = "@SQL=" + syncVal + " = 'True')";