如何确定 Outlook 文件夹是否是公共的?
我需要一种方法来确定 Outlook 文件夹是否是公共的。我怀疑有一些属性 Microsoft.Office.Interop.Outlook 允许我执行此操作,但我找不到它。
I need a way to determine if an Outlook folder is public. I suspect there is some property Microsoft.Office.Interop.Outlook that will allow me to do it, but I can't find it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以访问与相关文件夹关联的
IMsgStore
界面(抱歉,不知道如何使用纯 C# 实现这一点 - 我建议 赎回)您可以查询PR_MDB_PROVIDER
属性来查看它是否为pbExchangeProviderPublicGuid
。根据您对 KG 答案的评论更新:
如果您想过滤掉主邮箱中的联系人,只需将他们的
StoreID
与您的默认收件箱文件夹的 StoreID 进行比较即可 -或者一开始就不要枚举任何其他存储中的文件夹。If you can get at the
IMsgStore
interface associated with the folder in question (sorry, no idea how to do that with pure C# - I recommend Redemption) you could query thePR_MDB_PROVIDER
property to see whether it ispbExchangeProviderPublicGuid
.Update based on your comment to KG's answer:
If you want to filter out the contacts that are inside your primary mailbox, just compare their
StoreID
with that of your default inbox folder - or simply don't enumerate folders from any other stores to begin with.您想要的是 Exchange Web 服务,特别是 FindFolder 操作(请参阅 此处或此处< /a> 一些 MSDN 描述)。
尽管从表面上看,没有特定的属性来标识该文件夹是否是“公共”的,就像 @RedDeckWins 提到的那样。
更新
如果您没有特别要求为此使用托管 C#,则可以使用 Powershell Exchange Cmdlet(查看此处)。具体来说,这个命令可能会有所帮助:
Powershell 本身非常容易使用,但如果运行代码的服务器安装了它(对于大多数现代机器来说应该如此),也可以从 C# 调用它。
如果您仅限于 C#,请查看以下 StackOverflow 问题:交换中公共文件夹的电子邮件地址列表
What you want is Exchange Web Service, specifically the FindFolder operation (see here or here for some MSDN descriptions).
Although, from the looks of it, there is no specific property that identifies whether or not the folder is "public", like @RedDeckWins mentions.
UPDATE
If you are not specifically required to use managed C# for this, you can use the Powershell Exchange Cmdlets (check this out here). Specifically, this command might be helpful:
Powershell is pretty easy to use by itself, but it can also be called from C#, if the server your code is running on has it installed (which, for most modern boxes, should).
If you ARE limited to C#, take a look at this StackOverflow question: List of email address to public folders in exchange