当我在拉取订阅的帮助下获取创建的事件或通知时,为什么会出现“在商店中找不到指定的对象”的异常?
EWS SOAP响应如下所示:
<Trace Tag="EwsResponse" Tid="1" Time="2013-09-27 12:38:43Z" Version="15.00.0516.014">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="3" MajorBuildNumber="83" MinorBuildNumber="4" Version="Exchange2007_SP1" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Error">
<m:MessageText>The specified object was not found in the store.</m:MessageText>
<m:ResponseCode>ErrorItemNotFound</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items />
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</soap:Body>
这是我的代码:
PullSubscription subscription = service.SubscribeToPullNotifications(
new FolderId[] { WellKnownFolderName.Inbox }, 1, WaterMark,
EventType.NewMail, EventType.Created, EventType.Moved, EventType.Deleted);
WaterMark = subscription.Watermark;
// Initiate the GetEvents method for the new subscription.
GetEventsResults events = subscription.GetEvents();
// Handle the results of the GetEvents method.
foreach (ItemEvent itemEvent in events.ItemEvents)
{
switch (itemEvent.EventType)
{
case EventType.NewMail:
Console.WriteLine("New Mail");
EmailMessage message = EmailMessage.Bind(service, itemEvent.ItemId);
if (message.Subject.Equals(""))
{
break;
}
Item item = Item.Bind(service, itemEvent.ItemId);
RulesApplied(service, message, item);
break;
case EventType.Created:
Console.WriteLine("Created");
EmailMessage message1 = EmailMessage.Bind(service, itemEvent.ItemId);
// Here I get the Exception.
break;
答案 0 :(得分:3)
我发现在设置较低水印后邮箱所有者移动或删除邮件时会抛出此异常。
我相信ItemEvents集合包含受订阅事件影响的项目(例如新消息),但并非集合中的所有项目可能仍然相关 - 例如ItemId不再有效,因为它受到后续事件(如删除)的影响。
您可能会发现更频繁的轮询可以在最终用户触摸邮件之前捕获该项目,但是在我的组织内的应用程序中,我们只记录该异常,因为邮箱用户可能有特定的理由来移动或删除订阅的应用程序在消息事件上执行操作之前的消息。