SubscribeType 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
类 SubscribeType 表示订阅 Exchange 数据库中邮箱的事件通知的请求。
public ref class SubscribeType : ExchangeWebServices::BaseRequestType
public class SubscribeType : ExchangeWebServices.BaseRequestType
Public Class SubscribeType
Inherits BaseRequestType
- 继承
示例
下面的代码示例演示如何创建监视收件箱和另一个文件夹的拉取通知订阅。 当无法成功创建邮件的卷影副本时:
收件箱由 类标识, 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 获取或设置订阅类型。 此属性获取或设置 PullSubscriptionRequestType 或 PushSubscriptionRequestType 对象。 此属性是必需项。 这是一个读/写属性。 |