locked
Streaming notifications for multiple inboxes RRS feed

  • Question

  • Hi

    EWS 2010SP1 with managed api 1.1 in VS2010Pro

    Can I use a single subscription to get notifications for mailboxes belonging to different users or should I create one subscription per mailbox?

    Regards, Hogni


    • Edited by Hogni Wednesday, September 28, 2011 9:37 AM
    Wednesday, September 28, 2011 9:36 AM

Answers

  • Hi Hogni,

    you can do both.

    For additional reading, see my article on MSDN: http://msdn.microsoft.com/en-us/library/hh312849(EXCHG.140).aspx

    Kind regards,
    Henning

    • Marked as answer by Hogni Wednesday, September 28, 2011 10:20 AM
    Wednesday, September 28, 2011 10:00 AM
  • Ah.. ok, I misunderstood your question.

    You should use one subscription per mailbox. But you can use one StreamingSubscriptionConnection for all subscriptions.

    Kind regards,
    Henning

    • Marked as answer by Hogni Wednesday, September 28, 2011 10:20 AM
    Wednesday, September 28, 2011 10:19 AM

All replies

  • Hi Hogni,

    you can do both.

    For additional reading, see my article on MSDN: http://msdn.microsoft.com/en-us/library/hh312849(EXCHG.140).aspx

    Kind regards,
    Henning

    • Marked as answer by Hogni Wednesday, September 28, 2011 10:20 AM
    Wednesday, September 28, 2011 10:00 AM
  • Hi Henning

    I am using that article as reference and it is quite informative. Yet when I try to bind the subscription to multiple folder ids belonging to different users, having gotten the folder ids from impersonation of each user and Folder.Bind(wellknownfolder), the service instance reports an error that the folder was not found.

    If I go through the list of users and create a subscription for each on the same connection, things seem to work out just fine.

    Should I use a different method to get a folder id for each Inbox?

    Regards, Hogni


                    _log.Info("Wiring up Exchange connection");
                    _malaskraConnection = new StreamingSubscriptionConnection(_exchangeService, 30);
                    _malaskraConnection.OnDisconnect += SubscriptionDisconnected;
                    _malaskraConnection.OnSubscriptionError += SubscriptionError;
                    _malaskraConnection.OnNotificationEvent += MalaskraNotificationEvent;
                    EventType[] eventTypes = new[] { EventType.NewMail, EventType.Created };
    
                    foreach (XmlNode childNode in xml.DocumentElement.ChildNodes)
                    {
                        string alias = childNode.Attributes["alias"].Value;
                        _exchangeService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, ServiceFactory.MakeEmailAddress(alias));
                        var folderId = Folder.Bind(_exchangeService, WellKnownFolderName.Inbox).Id;
                        _streamingSubscription = _exchangeService.SubscribeToStreamingNotifications(new[]{folderId},
                                                                                                    eventTypes);
                        _malaskraConnection.AddSubscription(_streamingSubscription);
                        _log.Info("Wired inbox for " + ServiceFactory.MakeEmailAddress(alias));
                    }
    
                    _exchangeService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, _malaskraMailTestvisLocal);
                    _malaskraFolder = Folder.Bind(_exchangeService, WellKnownFolderName.Inbox);
                    _malaskraConnection.Open();
                    _log.Info("Successfully connected to exchange service");
    
    This is the implementation that I am using at the moment, and seems to work.
    • Edited by Hogni Wednesday, September 28, 2011 10:10 AM
    Wednesday, September 28, 2011 10:08 AM
  • Ah.. ok, I misunderstood your question.

    You should use one subscription per mailbox. But you can use one StreamingSubscriptionConnection for all subscriptions.

    Kind regards,
    Henning

    • Marked as answer by Hogni Wednesday, September 28, 2011 10:20 AM
    Wednesday, September 28, 2011 10:19 AM
  • Thank you (again :) )
    Wednesday, September 28, 2011 10:20 AM
  • Thanks :)
    Wednesday, September 28, 2011 10:20 AM