Jaa


GetEventsType Class

The GetEventsType class represents a request to get events for a pull notification subscription.

Inheritance Hierarchy

System.Object
  ExchangeWebServices.BaseRequestType
    ExchangeWebServices.GetEventsType

Namespace:  ExchangeWebServices
Assembly:  EWS (in EWS.dll)

Syntax

'Declaration
<SerializableAttribute> _
Public Class GetEventsType _
    Inherits BaseRequestType
'Usage
Dim instance As GetEventsType
[SerializableAttribute]
public class GetEventsType : BaseRequestType

Remarks

Changes to calendar items may result in the generation of multiple events. Operations on other items can also generate multiple low-level events. These events are the result of the creation of temporary items in the mailbox and changes to free/busy data storage items as part of the usual Calendar operations, or both. Events for item class IPM.SchedulePlus.FreeBusy.BinaryData should be ignored by Web services clients. These temporary items are deleted after they are created. If an attempt is made to retrieve these items, an error will be returned that states that the item was not found.

Examples

The following example shows you how to compose a request to get the events for a pull notification subscription. The watermark that is used to build the request must be the last watermark that is returned in the last GetEvents call or, if this is the first GetEvents call, the watermark from the Subscribe response. The watermark of the last event should be saved to be used for the next call to GetEvents.

static void GetEvents(ExchangeServiceBinding esb)
{ 
    // Create the GetEvents request.
    GetEventsType request = new GetEventsType();

    // Identify the subscription identifier and watermark for the subscription 
    // that will be polled for changes in the Exchange store.
    request.SubscriptionId = "2448550a-4685-412c-bc40-62f0999a8bdb";
    request.Watermark = "AQAAAM/SnQORsD1IqTUHelGT0oxxHQAAAAAAAAE=";

    // Send the request and get the response.
    GetEventsResponseType response = esb.GetEvents(request);
    ArrayOfResponseMessagesType aormt = response.ResponseMessages;
    ResponseMessageType[] rmta = aormt.Items;

    foreach (ResponseMessageType rmt in rmta)
    {
        // Determine whether the request was a success.
        if (rmt.ResponseClass == ResponseClassType.Success)
        {
            // Cast to appropriate response message type.
            GetEventsResponseMessageType responseMessage = (rmt as GetEventsResponseMessageType);

            // Get the notifications.
            NotificationType notificaton = responseMessage.Notification;
            BaseNotificationEventType[] bneta = notificaton.Items;

            foreach (BaseNotificationEventType bnet in bneta)
            {
                // TODO: Handle each notification. Refer to the Push Notification 
                //       sample for an example of how to do this.
            }

            if (notificaton.MoreEvents)
            {
                // TODO: Call GetEvents again with the watermark to get the
                //       remaining events.
            }
        }
    }
}

For more information about pull notifications, see Push Notification sample application.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.