交换公共文件夹的电子邮件地址列表
如何获取 Exchange 公用文件夹的所有电子邮件地址的列表?
我会自己回复,会接受最好的回复。
How do i get a list of all e-mail address for exchange public folders?
Will reply on my own, will accept the best reply offered.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然您作为自己的答案发布的内容可行,但阅读您正在使用的方法和对象的文档以了解它们的局限性会有所帮助。如果您多次调用此代码,您最终会遇到内存泄漏。
foreach
语句不会对所使用的对象调用Dispose()
,仅调用它创建的枚举器。下面是一种更好的搜索目录的方法(尽管很少进行错误检查并且没有异常处理)。注 1
DirectorySearcher.SizeLimit 的备注指示如果大小限制高于服务器确定的默认值(1000 个条目),则忽略该大小限制。分页使您可以根据需要获取所需的所有条目。
注2
DirectorySearcher.FindAll() 提到需要处置 SearchResultCollection 以释放资源。将其包装在
using
语句中可以清楚地表明您作为程序员的意图。额外
如果您使用的是 Exchange 2007 或 2010,您还可以安装 Exchange 管理工具并使用 powershell cmdlet 查询公用文件夹。您可以务实地创建 powershell 运行空间并直接调用 Exchange cmdlet,而实际上不需要用户与之交互的控制台。
While what you posted as your own answer would work, it helps to read the documentation for the methods and objects you are using to understand their limitations. If you had called this code multiple times you would eventually had a memory leak on your hands. The
foreach
statement doesn't callDispose()
on the object used, only the enumerator it creates. Below is a somewhat better method of searching the directory (though very little error checking and no exception handling).Note 1
The remarks for DirectorySearcher.SizeLimit indicate that the size limit is ignored if it is higher than the server-determined default (1000 entries). Paging allows you to get all of the entries you need as you need them.
Note 2
The remarks for DirectorySearcher.FindAll() mention that the SearchResultCollection needs to be disposed to release resources. Wrapping it in a
using
statement clearly identifies your intent as a programmer.Extra
If you're using Exchange 2007 or 2010 you could also install the Exchange Management Tools and use the powershell cmdlets to query your public folders. You can pragmatically create a powershell runspace and call the Exchange cmdlets directly without actually needing a console for the user to interact with.
以下代码将获取 Exchange 中公用文件夹的所有电子邮件地址的列表。
如果您想要公用文件夹的所有电子邮件地址,
请删除:
添加:
for (int counter = 0; counter < resEnt.Properties["proxyAddresses"].Count; counter++)
The following code will get a list of all email address of public folders in exchange.
If you want All email addresses of the public folder,
remove:
Add:
for (int counter = 0; counter < resEnt.Properties["proxyAddresses"].Count; counter++)