none
WCF Service to check emails in Inbox RRS feed

  • Question

  • I am creating a WCF Service that uses the Exchange Services Managed API SDK to retrieve new emails in a folder. I want to create a pull Subscription event for "NewMail" events in Inbox folder. My WCF service has the following methods:

    string Subscribe(); // Creates new subscription and returns watermark

    List<EmailMessage> GetEmails(string watermark, out string watermark);

    It is the second method GetEmails() that i require help. Since this is a WCF service, I want it to be stateless. With the watermark, I recreate the subscription object. Then I call GetEvents(), From the ItemId in ItemEvents, I get EmailMessage and send it back to the client.

    The client calls GetEmails() every 15 minutes.

    Do you think this will work? - especially recreating the subscription every 15 minutes with a watermark and using the subscription to get new emails for the last 15 minutes.

    TIA

    Vijay

    Tuesday, October 11, 2011 4:32 PM

Answers

All replies

  • Hi,

    since you are going with a stateless WebService and actually don't use the pull subscription features, I suggest another approach: Use the SyncFolderItems method to get change notifications for your inbox.

    See http://www.infinitec.de/post/2009/06/07/Processing-items-in-an-Exchange-folder-using-EWS-Managed-API.aspx and http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.exchangeservice.syncfolderitems(v=exchg.80).aspx.

    Kind regards,
    Henning

    If you get your question answered, please come back and mark the reply as an answer.
    If you are helped by an answer to someone else's question, please mark it as helpful.

    • Marked as answer by vijayst Wednesday, October 12, 2011 6:40 AM
    Tuesday, October 11, 2011 4:47 PM
  • Thank you, SyncFolder works. For the first time, I have to keep synching till all the synch is complete. The max number of records that can be synched is 512. I feel more comfortable using the SyncFolder solution than the Subscription.

    I feel EWS Managed API should allow to create a PullSubscription using a subscription id. This will make PullSubscription work well in REST scenarios. Recreating a subscription from a Watermark creates a PullSubscription with a new subscription id.

    The timestamp method is the simplest and it will work well. That was the alternative that I had in mind if nothing else works.

    Wednesday, October 12, 2011 6:44 AM