C#/Outlook - 检索特定的全局联系人

标签 c# outlook exchange-server contacts

我有两个问题:

1:我们有一个名为 Global Contacts 的公共(public) Outlook 文件夹,其中包含(您猜对了)大量联系人,每个人都可以在服务器上拥有一个帐户。

我可以使用此代码访问它:

            Microsoft.Office.Interop.Outlook._Application objOutlook; //declare Outlook application
            objOutlook = new Microsoft.Office.Interop.Outlook.Application(); //create it
            Microsoft.Office.Interop.Outlook._NameSpace objNS = objOutlook.Session; //create new session
            Microsoft.Office.Interop.Outlook.MAPIFolder oAllPublicFolders; //what it says on the tin
            Microsoft.Office.Interop.Outlook.MAPIFolder oPublicFolders; // as above
            Microsoft.Office.Interop.Outlook.MAPIFolder objContacts; //as above
            Microsoft.Office.Interop.Outlook.Items itmsFiltered; //the filtered items list
            oPublicFolders = objNS.Folders["Public Folders"];
            oAllPublicFolders = oPublicFolders.Folders["All Public Folders"];
            objContacts = oAllPublicFolders.Folders["Global Contacts"];

            itmsFiltered = objContacts.Items.Restrict(strFilter);//restrict the search to our filter terms

            for (int i = 1; i <= itmsFiltered.Count; i++) //loop through filtered items
            {
                 //do stuff
            }

一切都很好,花花公子。我还想做的是根据某种唯一 ID 检索一个特定联系人的版本...我该怎么做?

我可以使用某种唯一 ID 字段来检索联系人吗?还有比 Restrict() 更快的方法(它可能非常慢 - 我们有数千个联系人)?

2:有没有办法绕过 Outlook 2003 的“一个程序正在尝试访问您存储在 Outlook 中的电子邮件地址。您要允许吗?”每次运行这段代码时弹出的对话框?我知道这是一项安全功能,所以我猜答案很可能是“否”,但我还是想问问。

最佳答案

使用暴力从客户端浏览公共(public)联系人列表永远不会很快。我建议看看 Exchange Web Service (EWS) API通过服务器的 Web 服务实现您想要的功能。

您还可以使用 EWS 绕过来自 Outlook 的烦人消息。

绕过消息的另一种方法是直接使用 MAPI,并且 there are many examples .然而,MAPI 也有我之前提到的同样的问题:它不能快速地从客户端使用蛮力完成任务。

关于C#/Outlook - 检索特定的全局联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5679490/

相关文章:

excel - 将对象粘贴到空单元格/工作表时出现错误 424 未被识别为对象

Outlook 忽略宽度属性或 css 属性

powershell - $LastExitCode 不提供结果

c# - 上课时不阅读按钮单击时输入的表单

c# - Solr:如何搜索多个字段

c# - 为什么不从 List<T> 继承?

c# - 让表单重新检查 ModelView

powershell - 如何在 Outlook 中自动安排宏?

rest - 使用 Office365 REST API 检索用户照片

java - JAX-WS Sharepoint 401 未经授权的 NTLM