【发布时间】:2011-08-06 11:23:27
【问题描述】:
我有两个问题:
1:我们有一个名为 Global Contacts 的公共 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 中的电子邮件地址。您要允许这样做吗?”每次运行此代码时都会弹出对话框?我知道这是一项安全功能,所以我猜这个答案很可能是“不”,但我还是想问一下。
【问题讨论】:
标签: c# outlook exchange-server contacts