使用MAPI进行Outlook自定义字段过滤

时间:2016-09-23 12:12:45

标签: outlook outlook-addin

我尝试在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;

1 个答案:

答案 0 :(得分:2)

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

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