Share via


SubscribeType クラス

定義

クラスは SubscribeType 、Exchange データベース内のメールボックス上のイベントの通知をサブスクライブする要求を表します。

public ref class SubscribeType : ExchangeWebServices::BaseRequestType
public class SubscribeType : ExchangeWebServices.BaseRequestType
Public Class SubscribeType
Inherits BaseRequestType
継承
SubscribeType

次のコード例では、受信トレイと別のフォルダーを監視するプル通知サブスクリプションを作成する方法を示します。 その

受信トレイは クラスによって DistinguishedFolderIdType 識別され、もう一方のフォルダーは クラスによって FolderIdType 識別されます。 どちらのフォルダーも、新しい電子メール メッセージ、コピーされたアイテム、移動されたアイテム、変更されたアイテム、作成されたアイテム、および削除されたアイテムについて監視されます。 サブスクリプションがタイムアウトになるのは、GetEvents 呼び出しがタイムアウト間隔内に行われなかった場合のみです。

static void Subscribe(ExchangeServiceBinding esb)
{
    // Create the request.
    SubscribeType <span class="label">request</span> = new SubscribeType();

    // Identify the type of subscription.
    PullSubscriptionRequestType pullSub = new PullSubscriptionRequestType();

    // Identify the folders that are monitored for events.
    DistinguishedFolderIdType inbox = new DistinguishedFolderIdType();
    inbox.Id = DistinguishedFolderIdNameType.inbox;
    FolderIdType customFolder = new FolderIdType();
    customFolder.Id = "AQAlAE1=";
    pullSub.FolderIds = new BaseFolderIdType[2] { inbox, customFolder };

    // Identify the events that are monitored for the subscription.
    pullSub.EventTypes = new NotificationEventTypeType[6]
    {
        NotificationEventTypeType.CopiedEvent,
        NotificationEventTypeType.CreatedEvent,
        NotificationEventTypeType.DeletedEvent,
        NotificationEventTypeType.ModifiedEvent,
        NotificationEventTypeType.MovedEvent,
        NotificationEventTypeType.NewMailEvent
    };

    // Define the time-out period for the subscription (in minutes).
    pullSub.Timeout = 10;

<span class="label">request</span>.Item = pullSub;

    // Send the request and get the response.
    SubscribeResponseType response = esb.Subscribe(<span class="label">request</span>);

    ArrayOfResponseMessagesType aormt = response.ResponseMessages;
    ResponseMessageType[] rmta = aormt.Items;

    foreach (ResponseMessageType rmt in rmta)
    {
        // Cast to the appropriate response.
        SubscribeResponseMessageType respMsg = (rmt as SubscribeResponseMessageType);

        // Get the new subscription information.
        if (respMsg.ResponseClass == ResponseClassType.Success)
        {
            Console.WriteLine("New subscription: " + respMsg.SubscriptionId);
            Console.WriteLine("Watermark: " + respMsg.Watermark);
        }
    }
}

注釈

クラスは SubscribeType 、プッシュ通知とプル通知の両方の種類に使用されます。

コンストラクター

SubscribeType()

コンストラクターは SubscribeType 、 クラスの新しいインスタンスを SubscribeType 初期化します。

プロパティ

Item

プロパティは Item 、サブスクリプションの種類を取得または設定します。 このプロパティは、 または オブジェクトをPullSubscriptionRequestTypePushSubscriptionRequestType取得または設定します。 このプロパティは必須です。 これは、読み取り/書き込みプロパティです。

適用対象