如何使用 EWS 确定包含给定项目或文件夹的邮箱?
我有一个程序,它使用 EWS 托管 API 的流通知订阅多个 Exchange 2010 邮箱。
当我收到与某个项目相关的通知时,我需要确定该项目属于谁的邮箱。我能够获取项目的 ID 和父文件夹的 ID 等,但我看不到任何方法来确定该项目属于哪个邮箱。
I have a program that subscribes to multiple Exchange 2010 mailboxes using EWS Managed API's streaming notifications.
When I get a notification related to an item, I need to determine whose mailbox that item belongs to. I'm able to get the item's ID and the parent folder's ID, etc., but I don't see any way to determine what mailbox the item belongs to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,如果我正确理解您的应用程序,您正在使用模拟并为所有模拟用户创建订阅。当您从订阅接收事件时,您想知道该事件是为哪个用户发生的。如果是这种情况,您不能将订阅映射到为其创建订阅的用户吗?
简单的
Dictionary
就足够了当您收到通知时,您可以从
NotificationEventArgs.Subscription
属性获取订阅对象,并在映射中找到为其创建订阅的用户 ID。从ImpersonatedUserId
中,您可以获得 smtp 地址(属性Id
),并且您知道那是哪个用户。Ok, so if I understand your application correctly you are using Impersonation and create subscriptions for all impersonated users. And when you receive event from subscription you want to know for which user this event occurred. If that is the case can't you just keep your subscriptions mapped to user that subscription was created for?
Simple
Dictionary<StreamingSubscription, ImpersonateduserId>
would be enoughAnd when you get notification you get subscription object from
NotificationEventArgs.Subscription
property and find user id that subscription was created for in you map. FromImpersonatedUserId
you can get smtp address (propertyId
) and you know which exatcly user that was.这就是您获取该项目所属邮箱的电子邮件地址的方法。
That's how you get the Mailbox's Email Address that the item belongs to.