EWS托管API:检查响应

时间:2013-05-08 22:47:44

标签: exchange-server exchangewebservices ews-managed-api

我正在使用EWS托管API 2.0。我正在使用Calendaring部分,您可以按如下方式预约约会:

Appointment appointment = new Appointment(service);

//Set properties on the appointment.
appointment.Subject = "Dentist Appointment";
appointment.Body = "The appointment is with Dr. Smith.";
appointment.Start = new DateTime(2009, 3, 1, 9, 0, 0);
appointment.End = appointment.Start.AddHours(2);

//Save the appointment.
appointment.Save(SendInvitationsMode.SendToNone);

我如何使用API​​检查预订状态以及是否由于日期冲突(成功/错误/冲突)而预订?现在我可以通过outlook检查这个,但我想知道API中的这些信息。我查看了API文档,但找不到任何内容。

感谢您的帮助/指导。

1 个答案:

答案 0 :(得分:2)

在保存约会之前,您应首先检查所有与会者的可用性。 AvailabilityData将返回Result(ServiceResult.Success,ServiceResult.Warning或ServiceResult.Error),并且您可以检查ErrorMessage属性以查找每个冲突可用性的正确返回消息。如果任何与会者的可用性没有冲突,您可以保存您的约会对象。

AvailabilityOptions availabilityOptions = new AvailabilityOptions();
availabilityOptions.MeetingDuration = 60;
availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 4;
availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Good;
availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;

List<AttendeeInfo> attendees = new List<AttendeeInfo>();
attendees.Add(
    new AttendeeInfo()
    {
        SmtpAddress = "org@acme.com",
        AttendeeType = MeetingAttendeeType.Organizer
    });

attendees.Add(
    new AttendeeInfo()
    {
        SmtpAddress = "at1@acme.com",
        AttendeeType = MeetingAttendeeType.Required
    });

attendees.Add(
    new AttendeeInfo()
    {
        SmtpAddress = "room1@acme.com",
        AttendeeType = MeetingAttendeeType.Room
    });

GetUserAvailabilityResults availabilityResults =
        service.GetUserAvailability(
            attendees,
            new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)),
            AvailabilityData.FreeBusyAndSuggestions,
            availabilityOptions
        );

// Here check the availability Result and ErrorMessage of each attendees
// availabilityResults.AttendeesAvailability[0].Result
// availabilityResults.AttendeesAvailability[0].ErrorMessage
// ServiceResult.Success
// ServiceResult.Warning
// ServiceResult.Error