【问题标题】:EWS - List calendar appointments fails when trying to load attendeesEWS - 尝试加载与会者时列出日历约会失败
【发布时间】:2017-09-19 14:51:55
【问题描述】:

我正在尝试使用 C# EWS 2.0 库列出一些事件。

它正在使用以下代码:

    public IEnumerable<AppEvent> ListEvents(CalendarFolder folder, DateTime? startDate, DateTime? endDate)
    {
        var items = new List<AppEvent>();

        var now = DateTime.Now;
        if (startDate == null) startDate = DateTime.Now;
        if (endDate == null) endDate = now.AddDays(14);

        FindItemsResults<Appointment> findResults = null;
        ServiceResponseCollection<GetItemResponse> appointments = null;
        CalendarView view = null;

        view = new CalendarView((DateTime)startDate, (DateTime)endDate);
        findResults = folder.FindAppointments(view);

        if (findResults.Items.Count() == 0) return items;
        appointments = Service.BindToItems(findResults.Select(item => item.Id), AppointmentPropertySet);

        foreach (GetItemResponse item in appointments)
        {
            var appointment = item.Item as Appointment;
            try
            {
                if (appointment.IsCancelled) continue;
            }
            catch (System.NullReferenceException)
            {
                continue;
            }
            var evt = AppEvent.FromEWSAppointment(appointment);
            items.Add(evt);
        }

        return items;
    }

AppointmentPropertySet如下:

    protected PropertySet AppointmentPropertySet = new PropertySet(
        AppointmentSchema.Subject, 
        AppointmentSchema.Start,
        AppointmentSchema.End, 
        AppointmentSchema.IsAllDayEvent, 
        AppointmentSchema.IsMeeting,
        AppointmentSchema.IsRecurring, 
        AppointmentSchema.IsCancelled,
        AppointmentSchema.IsDraft, 
        AppointmentSchema.Location,
        AppointmentSchema.Resources,
        AppointmentSchema.RequiredAttendees, 
        AppointmentSchema.OptionalAttendees,
        AppointmentSchema.LegacyFreeBusyStatus,
        AppointmentSchema.Organizer, 
        AppointmentSchema.Body,
        AppointmentSchema.Sensitivity,
        AppointmentSchema.AppointmentReplyTime,
        AppointmentSchema.AppointmentSequenceNumber,
        AppointmentSchema.AppointmentState,
        AppointmentSchema.AppointmentType,
        AppointmentSchema.ConferenceType,
        AppointmentSchema.DateTimeCreated,
        AppointmentSchema.Duration,
        AppointmentSchema.EndTimeZone,
        AppointmentSchema.HasAttachments,
        AppointmentSchema.ICalDateTimeStamp,
        AppointmentSchema.ICalRecurrenceId,
        AppointmentSchema.ICalUid,
        AppointmentSchema.Id,
        AppointmentSchema.Importance,
        AppointmentSchema.IsOnlineMeeting,
        AppointmentSchema.IsReminderSet,
        AppointmentSchema.IsResponseRequested,
        AppointmentSchema.IsUnmodified,
        AppointmentSchema.LastModifiedTime,
        AppointmentSchema.LegacyFreeBusyStatus,
        AppointmentSchema.MeetingRequestWasSent,
        AppointmentSchema.MyResponseType,
        AppointmentSchema.MeetingWorkspaceUrl,
        AppointmentSchema.NetShowUrl,
        AppointmentSchema.OriginalStart,
        AppointmentSchema.ParentFolderId,
        AppointmentSchema.Recurrence,
        AppointmentSchema.ReminderDueBy,
        AppointmentSchema.ReminderMinutesBeforeStart,
        AppointmentSchema.StartTimeZone,
        AppointmentSchema.WebClientEditFormQueryString,
        AppointmentSchema.WebClientReadFormQueryString
        );

我们收到以下事件之一的错误。如果我从AppointmentPropertySet 中删除RequiredAttendeesOptionalAttendees,它可以正常工作(尽管没有返回与会者)。

如何避免此错误,或者如何跳过此事件,以便视图至少返回未中断的约会?

System.ArgumentException: Requested value 'User' was not found.
   at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
   at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
   at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
   at Microsoft.Exchange.WebServices.Data.EwsUtilities.Parse[T](String value)
   at Microsoft.Exchange.WebServices.Data.EwsXmlReader.ReadElementValue[T]()
   at Microsoft.Exchange.WebServices.Data.EmailAddress.TryReadElementFromXml(EwsServiceXmlReader reader)
   at Microsoft.Exchange.WebServices.Data.Attendee.TryReadElementFromXml(EwsServiceXmlReader reader)
   at Microsoft.Exchange.WebServices.Data.ComplexProperty.InternalLoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName, Func`2 readAction)
   at Microsoft.Exchange.WebServices.Data.ComplexProperty.LoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName)
   at Microsoft.Exchange.WebServices.Data.Attendee.TryReadElementFromXml(EwsServiceXmlReader reader)
   at Microsoft.Exchange.WebServices.Data.ComplexProperty.InternalLoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName, Func`2 readAction)
   at Microsoft.Exchange.WebServices.Data.ComplexProperty.LoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName)
   at Microsoft.Exchange.WebServices.Data.ComplexPropertyCollection`1.LoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String localElementName)
   at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.InternalLoadFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
   at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
   at Microsoft.Exchange.WebServices.Data.PropertyBag.LoadFromXml(EwsServiceXmlReader reader, Boolean clear, PropertySet requestedPropertySet, Boolean onlySummaryPropertiesRequested)
   at Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader.ReadServiceObjectsCollectionFromXml[TServiceObject](XmlNamespace collectionXmlNamespace, String collectionXmlElementName, GetObjectInstanceDelegate`1 getObjectInstanceDelegate, Boolean clearPropertyBag, PropertySet requestedPropertySet, Boolean summaryPropertiesOnly)
   at Microsoft.Exchange.WebServices.Data.GetItemResponse.ReadElementsFromXml(EwsServiceXmlReader reader)
   at Microsoft.Exchange.WebServices.Data.ServiceResponse.LoadFromXml(EwsServiceXmlReader reader, String xmlElementName)
   at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.ParseResponse(EwsServiceXmlReader reader)
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadResponse(EwsServiceXmlReader ewsXmlReader)
   at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponseXml(Stream responseStream)
   at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse response)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalBindToItems(IEnumerable`1 itemIds, PropertySet propertySet, ServiceErrorHandling errorHandling)
   at ExchangeAppService.Utilities.API.ExchangeAPI.ListEvents(CalendarFolder folder, Nullable`1 startDate, Nullable`1 endDate) in c:\Users\Some Guy\Documents\Visual Studio 2013\Projects\ExchangeAppService\ExchangeAppService\Utilities\API\Exchange\ExchangeAPI.cs:line 195

【问题讨论】:

  • 您还有这个问题吗?如果您已修复它,请将您的解决方案作为答案发布,它可能对遇到相同问题的其他人有用。
  • 我还在。
  • 你试过我的答案了吗?没用?
  • 是的,我有我认为是最新的 EWS 托管 API,但是,在 nuget 中,有几个选项,我不确定哪个是最好的。
  • 我还要注意,并非每次约会都会发生这种情况。只是其中一些。

标签: c# exchangewebservices ews-managed-api


【解决方案1】:

从异常堆栈跟踪来看,我很确定您的 Exchange 服务器正在回复一个(或多个)参加者电子邮件地址的 MailboxType 无效值(“用户”)。

查看current implementation of the MailboxType enum,即使是最新版本,“用户”的值似乎也是无效的。

您应该能够通过分析 Exchange 返回给您的肥皂响应、跟踪它(请参阅 How to: Trace requests and responses to troubleshoot EWS Managed API applications)或使用 Fiddler 或 Wireshark 等网络分析器来进一步确认这一点。

如果是这种情况,我认为唯一的解决方案是在他们的github repo 上打开一个问题,并希望他们可以为您提供更多信息或可能的解决方案。

【讨论】:

  • 看起来我将不得不与他们一起打开一个错误。感谢您的宝贵时间!
  • 没问题,我希望我不会很快遇到和你一样的问题:)
  • 另外,如果您在他们的 repo 上打开问题,请回来分享链接和/或结果,以便未来的人(包括我)可以找到解决方案或至少跟踪问题状态.
【解决方案2】:

2017 年 12 月 15 日在 github 中打开了一个问题。 https://github.com/OfficeDev/ews-managed-api/issues/145

还没有回复。我们已经开始在大约 30% 的客户邮箱中遇到同样的问题,我们担心这会蔓延

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 2017-02-16
    • 1970-01-01
    • 2013-01-26
    • 2017-11-18
    • 1970-01-01
    • 2021-07-27
    相关资源
    最近更新 更多