如何从GAL(全局地址列表)中获取addressEntry对象的完全匹配 [英] How to fetch exact match of addressEntry object from GAL (Global Address List)

查看:83
本文介绍了如何从GAL(全局地址列表)中获取addressEntry对象的完全匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用下面的C#代码在全局地址列表中搜索addressEntry对象.

I want to search for an addressEntry object in global address list using below code in C#.

Microsoft.Office.Interop.Outlook.Application app = new Outlook.Application();
Outlook.AddressList gal = app.Session.GetGlobalAddressList();
Outlook.AddressEntry entry = gal.AddressEntries[name];

但是我得到了第一个匹配的名字,这是不正确的.我想将别名或primarySMTPAddress(mailId)作为唯一索引传递.给我方法传递唯一值以获取确切的addressEntry对象.另一种获取所有匹配的addressEntry对象的方法.

But i got the 1st matched name which is not correct. I want to pass alias or primarySMTPAddress(mailId) as index which is unique. Give me the method to pass unique value to get exact addressEntry Object. Else method to fetch all the matching addressEntry objects.

您还可以为以下代码段建议可能的索引参数.

And you can suggest the possible index parameters for below snippet.

Outlook.AddressEntry entry = gal.AddressEntries[name];

推荐答案

您需要遍历所有项以找到完全匹配的项. Outlook对象模型没有为此提供任何方法或属性.

You need to iterate over all items to find the exact match. The Outlook object model doesn't provide any method or property for that.

使用Dmitry建议的低级代码(扩展MAPI),可以在PR_ANR上创建RES_PROPERTY限制,并在相应IABContainer对象的内容表上调用IMAPITable :: Restrict.这与Outlook在针对特定容器解析名称并显示模糊的名称对话框时使用的限制相同.

Using a low-level code (Extended MAPI) as Dmitry suggested you can create a RES_PROPERTY restriction on PR_ANR and call IMAPITable::Restrict on the contents table of the corresponding IABContainer object. This is the same restriction used by Outlook when it resolves a name against a particular container and shows an ambiguous name dialog.

这篇关于如何从GAL(全局地址列表)中获取addressEntry对象的完全匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆